Skip to content
This repository was archived by the owner on Dec 20, 2022. It is now read-only.

Latest commit

 

History

History
42 lines (28 loc) · 9.14 KB

File metadata and controls

42 lines (28 loc) · 9.14 KB

forkJoin or allWithNotifications or allN

function forkJoin<GObservables extends IGenericForkInObservables>(
  observables: GObservables,
): IObservable<IForkJoinObservableNotifications<GObservables>

forkJoin will wait for all passed observables to complete (complete Notification) and then it will emit an array with the last values received through the next Notifications for each observable. Finally, it will complete (complete Notification).

It is somehow equivalent of a Promise.all.

Diagram

Examples

Example 1

const observable1$ = singleN(false);
const observable2$ = mergeMapS$$(timeout(2000), () => singleN(true)); // emits 'true' after 2000ms

const result$ = forkJoin([observable1$, observable2$]);

result$((notification) => {
  console.log(notification.name, notification.value);
});

Output:

// 2000ms
'next', [false, true]
'complete', undefined