Skip to content

Commit

Permalink
fix(forkJoin): fix forkJoin to complete if sources Array is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
trxcllnt authored and kwonoj committed Jan 13, 2016
1 parent c5ead88 commit 412b13b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spec/observables/forkJoin-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ describe('Observable.forkJoin', function () {
expectObservable(e1).toBe(expected);
});

it('should complete if sources list is empty', function () {
var e1 = Observable.forkJoin([]);
var expected = '|';

expectObservable(e1).toBe(expected);
});

it('should complete when any of source is empty with selector', function () {
function selector(x, y) {
return x + y;
Expand Down Expand Up @@ -242,4 +249,4 @@ describe('Observable.forkJoin', function () {

expectObservable(e1).toBe(expected);
});
});
});
4 changes: 4 additions & 0 deletions src/observable/forkJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export class ForkJoinObservable<T> extends Observable<T> {
sources = <Array<Observable<any>>>sources[0];
}

if (sources.length === 0) {
return new EmptyObservable<T>();
}

return new ForkJoinObservable(<Array<Observable<any> | Promise<any>>>sources, resultSelector);
}

Expand Down

0 comments on commit 412b13b

Please sign in to comment.