robinchew
10/17/2018, 4:12 PMdata class GlobalState( val count: Int = 0)
val subject = PublishSubject.create<(GlobalState) -> GlobalState>();
subject.scan(
GlobalState(),
{old, new -> new(old)}
).subscribe {println("emits: ${it}")}
subject.onNext({ state -> state.copy(count=2)})
subject.onNext({ state -> state.copy(count=5)})