In RxJS, when you need to combine two Observables and emit only when one of those emits, you use withLatestFrom
source$.pipe(
withLatestFrom(other$),
map(([sourceValue, otherValue]) => ...) // this is only executed when `source$` has new values, regardless of `other$` emission
)
If source$ emits multiple times but other$ don't, you always get the same, latest, value and do execute map.
If you don't need the value of the "signalling" stream, you can use sample.
interestingStream$.pipe(
sample(signallingStream$),
map((interestingValue) => ...) // this function does not receive `signallingStream$`'s values
)
However, map is only executed if signallingStream$ emits after interestingStream$ emitted a new value; no value is emitted twice downstream.
So my question is, is there an operator, a combination of operators, or something else that allows me to get multiple times the latest value of a source stream without forcing me to get and ignore the value of a signalling stream like in the following snippet?
signallingStream$.pipe(
withLatestFrom(interestingStream$),
map(([_ignore_, interestingValue]) => interestingValue),
)