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(endWith): wrap args - they are not observables - in of before concatenating #4735

Merged
merged 3 commits into from May 2, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions spec/operators/endWith-spec.ts
Expand Up @@ -20,6 +20,16 @@ describe('endWith operator', () => {
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});

it('should append numbers to a cold Observable', () => {
const values = { a: 1, b: 2, c: 3, s: 4 };
const e1 = cold('---a--b--c--|', values);
const e1subs = '^ !';
const expected = '---a--b--c--(s|)';

expectObservable(e1.pipe(endWith(values.s))).toBe(expected, values);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});

it('should end an observable with given value', () => {
const e1 = hot('--a--|');
const e1subs = '^ !';
Expand Down
3 changes: 2 additions & 1 deletion src/internal/operators/endWith.ts
@@ -1,5 +1,6 @@
import { Observable } from '../Observable';
import { concat } from '../observable/concat';
import { of } from '../observable/of';
import { MonoTypeOperatorFunction, SchedulerLike, OperatorFunction } from '../types';

/* tslint:disable:max-line-length */
Expand Down Expand Up @@ -62,5 +63,5 @@ export function endWith<T, Z = T>(...array: Array<Z | SchedulerLike>): OperatorF
* @owner Observable
*/
export function endWith<T>(...array: Array<T | SchedulerLike>): MonoTypeOperatorFunction<T> {
return (source: Observable<T>) => concat(source, ...(array as any[])) as Observable<T>;
return (source: Observable<T>) => concat(source, of(...array)) as Observable<T>;
}