Skip to content

Like RxJS forkJoin operator, but deep traversal of the source. ✌️

License

Notifications You must be signed in to change notification settings

ystarlongzi/fork-join-deep

Repository files navigation

fork-join-deep

Like RxJS forkJoin operator, but deep traversal of the source.


Build Status codecov npm npm MIT license PRs Welcome

Installation

npm i --save fork-join-deep

Feature

1. Support primitive values. (codesandbox)

❌ forkJoin

forkJoin({
  a: 0,
}).subscribe((result) => {
  console.log(result);
  // ↓↓↓ output ↓↓↓
  // Error: You provided '0' where a stream was expected.
  // You can provide an Observable, Promise, Array, or Iterable.
});

✅ forkJoinDeep

forkJoinDeep({
  a: 0,
}).subscribe((result) => {
  console.log(result);
  // ↓↓↓ output ↓↓↓
  // {a: 0}
});

2. Support nested objects. (codesandbox)

❌ forkJoin

forkJoin({
  a: {
    a1: of(0),
  },
}).subscribe((result) => {
  console.log(result);
  // ↓↓↓ output ↓↓↓
  // Error: You provided '0' where a stream was expected.
  // You can provide an Observable, Promise, Array, or Iterable.
});

✅ forkJoinDeep

forkJoinDeep({
  a: {
    a1: of(0),
  },
}).subscribe((result) => {
  console.log(result);
  // ↓↓↓ output ↓↓↓
  // {a: a1: {0}}
});

3. Support Higher-order Observables. (codesandbox)

❌ forkJoin

forkJoin({
  a: of(of(0)),
}).subscribe((result) => {
  console.log(result);
  // ↓↓↓ output ↓↓↓
  // {a: Observable}
});

✅ forkJoinDeep

forkJoinDeep({
  a: of(of(0)),
}).subscribe((result) => {
  console.log(result);
  // ↓↓↓ output ↓↓↓
  // {a: 0}
});

LICENSE

MIT