Tom Larkworthy
Tom Larkworthy

Reputation: 2384

How to sync streams of different frequencies

I have two streams of radically different frequencies, A and B. I want a new stream at frequency A, which is of the value {A, last_value_of(B)}.

zip returns A and B in lockstep, so the output frequency will be the slowest, so that is no good.

combineLatest will return a result for every change on either stream, so it's frequency is A + B, no good.

I want to somehow designate A to be the master stream and for B's latest values to be synced on propagation of an A event.

Upvotes: 0

Views: 79

Answers (1)

Brandon
Brandon

Reputation: 39222

You want withLatestFrom

a.withLatestFrom(b, (aa, bb) => [aa, bb]).subscribe(...);

Upvotes: 4

Related Questions