combineLatest

signature:


combineAll can be used to apply combineLatest to emitted
observables when a source completes!


This operator is best used when you have multiple, long-lived observables that
rely on eachother for some calculation or determination. Basic examples of this
can be seen in ,
where events from multiple buttons are being combined to produce a count of each
and an overall total, or a
calculation of BMI
from the RxJS documentation.

Lastly, if you are working with observables that only emit one value, or you
only require the last value of each before completion,
is likely a better option.

combineLatest - 图3

(

)

Example 1: Combining observables emitting at 3 intervals
Example 2: combineLatest with projection function

( StackBlitz |
|
jsFiddle )

Example 3: Combining events from 2 buttons

( StackBlitz |
|
jsFiddle )

HTML