package Ġpress . theme Ċ Ċ import Ġandroid . view . View Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġcom . jak ew h art on . r xb ind ing 3 . view . att aches Ċ import Ġcom . jak ew h art on . r xb ind ing 3 . view . det aches Ċ import Ġio . reactivex . Observable Ċ import Ġme . s aket . press . shared . theme . App Theme Ċ import Ġme . s aket . press . shared . theme . Theme Palette Ċ import Ġme . s aket . press . shared . theme . listen Rx Ċ import Ġpress . Press App Ċ import Ġpress . extensions . on Dest ro ys Ċ Ċ fun Ġapp Theme (): ĠApp Theme Ġ= ĠPress App . component . theme () Ċ Ċ fun Ġtheme Palette (): ĠObservable < Theme Palette > Ġ= ĊĠ Ġapp Theme (). listen Rx () Ċ Ċ fun ĠView . theme Aware ( on Theme Change : Ġ( Theme Palette ) Ġ-> ĠUnit ) Ġ{ ĊĠ Ġval Ġstream Ġ= Ġtheme Palette () ĊĠ Ġatt aches () ĊĠĠĠ Ġ. switch Map Ġ{ Ġstream Ġ} ĊĠĠĠ Ġ. take Until ( det aches ()) ĊĠĠĠ Ġ. merge With ( stream . take ( 1 )) Ġ Ġ// ĠDon 't Ġwait Ġtill Ġattach Ġfor Ġthe Ġfirst Ġemission . ĊĠĠĠ Ġ. distinct Until Changed () ĊĠĠĠ Ġ. subscribe Ġ{ Ġon Theme Change ( it ) Ġ} Ċ } Ċ Ċ fun ĠAppCompatActivity . theme Aware ( on Theme Change : Ġ( Theme Palette ) Ġ-> ĠUnit ) Ġ{ ĊĠ Ġtheme Palette () ĊĠĠĠ Ġ. take Until ( on Dest ro ys ()) ĊĠĠĠ Ġ. subscribe Ġ{ Ġon Theme Change ( it ) Ġ} Ċ } Ċ