ReferencewithLatestFrom
Reference · 30
withLatestFrom
withLatestFrom
Adds the second stream's latest value to the main stream's value.
Signature
withLatestFrom(other$: ObservableInput): OperatorFunction
Marble diagram
main: --a---b---c---|
other: ---1---2------|
result: ------[b,1]-[c,2]-|
What it does
Emits only when the main stream ticks. It attaches the latest value of the "passive" other$ to the main value. If other$ hasn't emitted yet, the main value is ignored.
When to use
A click + the current filter state, a form submit + the current user, an event + config. When other$ is needed only as context, not as a trigger.
See also
combineLatest, sample, switchMap
script.ts
CONSOLE · Console output
Hit Run to see the result...