iex
02/25/2020, 4:03 PMprivate val dealerButtonTrigger: PublishSubject<Unit> = PublishSubject.create()
init {
dealerButtonTrigger.withLatestFrom(dealerAction.toObservable())
.subscribe { (_, action) ->
action.handle()
}
}
Here, when I click (i.e. call dealerButtonTrigger.onNext(Unit)
) after updating the dealer and navigating back, it still gives me the first dealer. Shouldn't it get the updated value?Zach Klippenstein (he/him) [MOD]
02/25/2020, 4:27 PMdealerAction
is a Single
– it only emits a single value. It doesn’t have the concept of “updated value”. If the value can change over time, it should be an Observable
, and the object backing dealerAction
should have some way of signaling that the value changed.toObservable()
just changes the type, it doesn’t magically add logic that knows how to detect when your data sources changes.iex
02/25/2020, 4:52 PMtoObservable()
)