RXJS withLatestFrom
Thu Jun 30 2022 17:04:08 GMT+0000 (Coordinated Universal Time)
Saved by
@Polly
/**
* Only emit from 1st(source) 2nd(inner) obs after both have emitted (onFirst of each) - don't need to complete
* Only emit the last value present ( of each )
* if one obs completes, the output is the data from the one running plus the last value from the the one completed
* returns a tuple [data1, data2] of each obs-dataset, similar to forkJoin
*/
1$ = from(http src) -> complete
2$ = from( http src ) -> long running
1$.pipe(withLatestFrom(2$)).subscribe([ dataFrom1, dataFrom2])
content_copyCOPY
Use case
intergrating multiple observables of different types
1 http - completes
2 http - continues listening
out come = display new values when any
Comments