Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(merge/concat): merging or concatenating scalar observables will now com… #1315

Merged
merged 1 commit into from
Feb 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions spec/operators/concat-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@ describe('Observable.prototype.concat()', function () {
expectObservable(e1.concat(e2, rxTestScheduler)).toBe(expected);
});

it('should work properly with scalar observables', function (done) {
var results = [];

var s1 = Observable
.create(function (observer) {
setTimeout(function () {
observer.next(1);
observer.complete();
});
})
.concat(Observable.of(2));

s1.subscribe(
function (x) {
results.push('Next: ' + x);
},
done.fail,
function (x) {
results.push('Completed');
expect(results).toEqual(['Next: 1', 'Next: 2', 'Completed']);
done();
}
);
});

it('should complete without emit if both sources are empty', function () {
var e1 = cold('--|');
var e1subs = '^ !';
Expand Down
8 changes: 2 additions & 6 deletions src/operator/mergeAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ export class MergeAllSubscriber<T> extends OuterSubscriber<Observable<T>, T> {

protected _next(observable: Observable<T>) {
if (this.active < this.concurrent) {
if (observable._isScalar) {
this.destination.next((<any>observable).value);
} else {
this.active++;
this.add(subscribeToResult<Observable<T>, T>(this, observable));
}
this.active++;
this.add(subscribeToResult<Observable<T>, T>(this, observable));
} else {
this.buffer.push(observable);
}
Expand Down