package Ġio . red green . on ew ay . catalog ue . lot sof counters Ċ Ċ import Ġio . reactivex . Observable Ċ import Ġio . reactivex . rx kotlin . with Latest From Ċ import Ġio . red green . on ew ay . Source Lifecycle Event Ċ import Ġio . red green . on ew ay . use cases . Source Created UseCase Ċ import Ġio . red green . on ew ay . use cases . Source Restore d UseCase Ċ Ċ object ĠL ots Of Counters Model Ġ{ ĊĠ Ġfun Ġcreate Source ( ĊĠĠĠĠĠ Ġintent ions : ĠObservable < L ots Of Counters Int ention >, ĊĠĠĠĠĠ Ġsource Lifecycle Events : ĠObservable < Source Lifecycle Event >, ĊĠĠĠĠĠ Ġsource Copy : ĠObservable < L ots Of Counters State > ĊĠ Ġ): ĠObservable < L ots Of Counters State > Ġ{ ĊĠĠĠ Ġval Ġadd Counter States Ġ= Ġintent ions ĊĠĠĠĠĠĠĠ Ġ. of Type ( Add Counter Int ention :: class . java ) ĊĠĠĠĠĠĠĠ Ġ. with Latest From ( source Copy ) Ġ{ Ġ_, Ġstate Ġ-> Ġstate . add Counter () Ġ} ĊĊĠĠĠ Ġval Ġincrement Counter States Ġ= Ġintent ions ĊĠĠĠĠĠĠĠ Ġ. of Type ( Increment Counter At Int ention :: class . java ) ĊĠĠĠĠĠĠĠ Ġ. with Latest From ( source Copy ) Ġ{ Ġintention , Ġstate Ġ-> Ġstate . increment Counter ( int ention . index ) Ġ} ĊĊĠĠĠ Ġval Ġdecrement Counter States Ġ= Ġintent ions ĊĠĠĠĠĠĠĠ Ġ. of Type ( De crement Counter At Int ention :: class . java ) ĊĠĠĠĠĠĠĠ Ġ. with Latest From ( source Copy ) Ġ{ Ġintention , Ġstate Ġ-> Ġstate . decrement Counter ( int ention . index ) Ġ} ĊĊĠĠĠ Ġval Ġremove Counter States Ġ= Ġintent ions ĊĠĠĠĠĠĠĠ Ġ. of Type ( Remove Counter At Int ention :: class . java ) ĊĠĠĠĠĠĠĠ Ġ. with Latest From ( source Copy ) Ġ{ Ġintention , Ġstate Ġ-> Ġstate . remove Counter ( int ention . index ) Ġ} ĊĊĠĠĠ Ġreturn ĠObservable . merge Array ( ĊĠĠĠĠĠĠĠ Ġsource Lifecycle Events . compose ( Source Created UseCase ( L ots Of Counters State . NO _ COUNTER S )), ĊĠĠĠĠĠĠĠ Ġsource Lifecycle Events . compose ( Source Restore d UseCase ( source Copy )), ĊĠĠĠĠĠĠĠ Ġadd Counter States , ĊĠĠĠĠĠĠĠ Ġincrement Counter States , ĊĠĠĠĠĠĠĠ Ġdecrement Counter States , ĊĠĠĠĠĠĠĠ Ġremove Counter States ĊĠĠĠ Ġ) ĊĠ Ġ} Ċ } Ċ