import { interval, forkJoin, of } from 'rxjs';
import { delay, take } from 'rxjs/operators';
setTimeout(() => resolve(`Promise Resolved: ${val}`), 5000)
when all observables complete, give the last
emitted value from each as an array
const example = forkJoin({
//emit 'Hello' immediately
//emit 'World' after 1 second
sourceTwo: of('World').pipe(delay(1000)),
sourceThree: interval(1000).pipe(take(1)),
//emit 0...1 in 1 second interval
sourceFour: interval(1000).pipe(take(2)),
//promise that resolves to 'Promise Resolved' after 5 seconds
sourceFive: myPromise('RESULT')
* sourceFive: "Promise Resolved: RESULT"
const subscribe = example.subscribe(val => console.log(val));