function
stable
Combines the source Observable with other Observables to create an Observable whose values are calculated from the latest values of each, only when the source emits.
withLatestFrom<T, R>(...args: Array<ObservableInput<any> | ((...values: Array<any>) => R)>): OperatorFunction<T, R>
args | Type: |
OperatorFunction<T, R>
: An Observable of projected values from the most recent values from each input Observable, or an array of the most recent values from each input Observable.
Whenever the source Observable emits a value, it computes a formula using that value plus the latest values from other input Observables, then emits the output of that formula.
withLatestFrom
combines each value from the source Observable (the instance) with the latest values from the other input Observables only when the source emits a value, optionally using a project
function to determine the value to be emitted on the output Observable. All input Observables must emit at least one value before the output Observable will emit a value.
On every click event, emit an array with the latest timer event plus the click event
import { fromEvent, interval } from 'rxjs'; import { withLatestFrom } from 'rxjs/operators'; const clicks = fromEvent(document, 'click'); const timer = interval(1000); const result = clicks.pipe(withLatestFrom(timer)); result.subscribe(x => console.log(x));
withLatestFrom(project: (v1: T) => R): OperatorFunction<T, R>
project | Type: |
OperatorFunction<T, R>
withLatestFrom(source2: O2, project: (v1: T, v2: ObservedValueOf<O2>) => R): OperatorFunction<T, R>
source2 | Type: |
project | Type: |
OperatorFunction<T, R>
withLatestFrom(v2: O2, v3: O3, project: (v1: T, v2: ObservedValueOf<O2>, v3: ObservedValueOf<O3>) => R): OperatorFunction<T, R>
v2 | Type: |
v3 | Type: |
project | Type: |
OperatorFunction<T, R>
withLatestFrom(v2: O2, v3: O3, v4: O4, project: (v1: T, v2: ObservedValueOf<O2>, v3: ObservedValueOf<O3>, v4: ObservedValueOf<O4>) => R): OperatorFunction<T, R>
v2 | Type: |
v3 | Type: |
v4 | Type: |
project | Type: |
OperatorFunction<T, R>
withLatestFrom(v2: O2, v3: O3, v4: O4, v5: O5, project: (v1: T, v2: ObservedValueOf<O2>, v3: ObservedValueOf<O3>, v4: ObservedValueOf<O4>, v5: ObservedValueOf<O5>) => R): OperatorFunction<T, R>
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
project | Type: |
OperatorFunction<T, R>
withLatestFrom(v2: O2, v3: O3, v4: O4, v5: O5, v6: O6, project: (v1: T, v2: ObservedValueOf<O2>, v3: ObservedValueOf<O3>, v4: ObservedValueOf<O4>, v5: ObservedValueOf<O5>, v6: ObservedValueOf<O6>) => R): OperatorFunction<T, R>
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
v6 | Type: |
project | Type: |
OperatorFunction<T, R>
withLatestFrom(source2: O2): OperatorFunction<T, [T, ObservedValueOf<O2>]>
source2 | Type: |
OperatorFunction<T, [T, ObservedValueOf<O2>]>
withLatestFrom(v2: O2, v3: O3): OperatorFunction<T, [T, ObservedValueOf<O2>, ObservedValueOf<O3>]>
v2 | Type: |
v3 | Type: |
OperatorFunction<T, [T, ObservedValueOf<O2>, ObservedValueOf<O3>]>
withLatestFrom(v2: O2, v3: O3, v4: O4): OperatorFunction<T, [T, ObservedValueOf<O2>, ObservedValueOf<O3>, ObservedValueOf<O4>]>
v2 | Type: |
v3 | Type: |
v4 | Type: |
OperatorFunction<T, [T, ObservedValueOf<O2>, ObservedValueOf<O3>, ObservedValueOf<O4>]>
withLatestFrom(v2: O2, v3: O3, v4: O4, v5: O5): OperatorFunction<T, [T, ObservedValueOf<O2>, ObservedValueOf<O3>, ObservedValueOf<O4>, ObservedValueOf<O5>]>
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
OperatorFunction<T, [T, ObservedValueOf<O2>, ObservedValueOf<O3>, ObservedValueOf<O4>, ObservedValueOf<O5>]>
withLatestFrom(v2: O2, v3: O3, v4: O4, v5: O5, v6: O6): OperatorFunction<T, [T, ObservedValueOf<O2>, ObservedValueOf<O3>, ObservedValueOf<O4>, ObservedValueOf<O5>, ObservedValueOf<O6>]>
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
v6 | Type: |
OperatorFunction<T, [T, ObservedValueOf<O2>, ObservedValueOf<O3>, ObservedValueOf<O4>, ObservedValueOf<O5>, ObservedValueOf<O6>]>
withLatestFrom(...observables: Array<ObservableInput<any> | ((...values: Array<any>) => R)>): OperatorFunction<T, R>
observables | Type: |
OperatorFunction<T, R>
withLatestFrom(array: ObservableInput<any>[]): OperatorFunction<T, R>
array | Type: |
OperatorFunction<T, R>
withLatestFrom(array: ObservableInput<any>[], project: (...values: Array<any>) => R): OperatorFunction<T, R>
array | Type: |
project | Type: |
OperatorFunction<T, R>
© 2015–2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/operators/withLatestFrom