iex
02/25/2020, 4:08 PMflatMap
instead of withLatestFrom
, but curious why withLatestFrom
doesn't. I thought it will get the current value at the point of time I activate the subject.Zach Klippenstein (he/him) [MOD]
02/25/2020, 4:32 PMflatMap
works is because flatMap
will resubscribe every time the upstream observable emits. And since dealerAction
is a Single
, it will only compute the value on subscription.
So with flatMap
, every time you click, you’re re-subscribing to dealerAction
, which re-reads the preference, and you get your new value. With withLatestFrom
, dealerAction
is only subscribed to once, and since it’s a Single
it will only emit once.iex
02/25/2020, 4:53 PM