import { Observable } from '../Observable'; import { isArray } from '../util/isArray'; import { map } from '../operators/map'; import { isObject } from '../util/isObject'; import { from } from './from'; export function forkJoin(...sources) { if (sources.length === 1) { const first = sources[0]; if (isArray(first)) { return forkJoinInternal(first, null); } if (isObject(first) && Object.getPrototypeOf(first) === Object.prototype) { const keys = Object.keys(first); return forkJoinInternal(keys.map(key => first[key]), keys); } } if (typeof sources[sources.length - 1] === 'function') { const resultSelector = sources.pop(); sources = (sources.length === 1 && isArray(sources[0])) ? sources[0] : sources; return forkJoinInternal(sources, null).pipe(map((args) => resultSelector(...args))); } return forkJoinInternal(sources, null); } function forkJoinInternal(sources, keys) { return new Observable(subscriber => { const len = sources.length; if (len === 0) { subscriber.complete(); return; } const values = new Array(len); let completed = 0; let emitted = 0; for (let i = 0; i < len; i++) { const source = from(sources[i]); let hasValue = false; subscriber.add(source.subscribe({ next: value => { if (!hasValue) { hasValue = true; emitted++; } values[i] = value; }, error: err => subscriber.error(err), complete: () => { completed++; if (completed === len || !hasValue) { if (emitted === len) { subscriber.next(keys ? keys.reduce((result, key, i) => (result[key] = values[i], result), {}) : values); } subscriber.complete(); } } })); } }); } //# sourceMappingURL=forkJoin.js.map
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
dom | Folder | 0755 |
|
|
ConnectableObservable.js | File | 4.14 KB | 0644 |
|
ConnectableObservable.js.map | File | 3.82 KB | 0644 |
|
SubscribeOnObservable.js | File | 1.14 KB | 0644 |
|
SubscribeOnObservable.js.map | File | 1.2 KB | 0644 |
|
bindCallback.js | File | 2.82 KB | 0644 |
|
bindCallback.js.map | File | 2.83 KB | 0644 |
|
bindNodeCallback.js | File | 3.25 KB | 0644 |
|
bindNodeCallback.js.map | File | 3.23 KB | 0644 |
|
combineLatest.js | File | 2.82 KB | 0644 |
|
combineLatest.js.map | File | 2.86 KB | 0644 |
|
concat.js | File | 200 B | 0644 |
|
concat.js.map | File | 308 B | 0644 |
|
defer.js | File | 516 B | 0644 |
|
defer.js.map | File | 636 B | 0644 |
|
empty.js | File | 375 B | 0644 |
|
empty.js.map | File | 521 B | 0644 |
|
forkJoin.js | File | 2.2 KB | 0644 |
|
forkJoin.js.map | File | 2.43 KB | 0644 |
|
from.js | File | 441 B | 0644 |
|
from.js.map | File | 489 B | 0644 |
|
fromArray.js | File | 399 B | 0644 |
|
fromArray.js.map | File | 446 B | 0644 |
|
fromEvent.js | File | 2.45 KB | 0644 |
|
fromEvent.js.map | File | 2.53 KB | 0644 |
|
fromEventPattern.js | File | 926 B | 0644 |
|
fromEventPattern.js.map | File | 1.09 KB | 0644 |
|
fromIterable.js | File | 499 B | 0644 |
|
fromIterable.js.map | File | 529 B | 0644 |
|
fromPromise.js | File | 415 B | 0644 |
|
fromPromise.js.map | File | 450 B | 0644 |
|
generate.js | File | 3.39 KB | 0644 |
|
generate.js.map | File | 2.88 KB | 0644 |
|
iif.js | File | 237 B | 0644 |
|
iif.js.map | File | 364 B | 0644 |
|
interval.js | File | 758 B | 0644 |
|
interval.js.map | File | 945 B | 0644 |
|
merge.js | File | 901 B | 0644 |
|
merge.js.map | File | 995 B | 0644 |
|
never.js | File | 203 B | 0644 |
|
never.js.map | File | 307 B | 0644 |
|
of.js | File | 413 B | 0644 |
|
of.js.map | File | 511 B | 0644 |
|
onErrorResumeNext.js | File | 763 B | 0644 |
|
onErrorResumeNext.js.map | File | 941 B | 0644 |
|
pairs.js | File | 1.29 KB | 0644 |
|
pairs.js.map | File | 1.52 KB | 0644 |
|
partition.js | File | 441 B | 0644 |
|
partition.js.map | File | 562 B | 0644 |
|
race.js | File | 2.04 KB | 0644 |
|
race.js.map | File | 2.01 KB | 0644 |
|
range.js | File | 1.14 KB | 0644 |
|
range.js.map | File | 1.19 KB | 0644 |
|
throwError.js | File | 421 B | 0644 |
|
throwError.js.map | File | 565 B | 0644 |
|
timer.js | File | 1.12 KB | 0644 |
|
timer.js.map | File | 1.29 KB | 0644 |
|
using.js | File | 898 B | 0644 |
|
using.js.map | File | 939 B | 0644 |
|
zip.js | File | 5.7 KB | 0644 |
|
zip.js.map | File | 5.67 KB | 0644 |
|