diff --git a/spec/operators/endWith-spec.ts b/spec/operators/endWith-spec.ts index 0da37e53a5..f42d33bc65 100644 --- a/spec/operators/endWith-spec.ts +++ b/spec/operators/endWith-spec.ts @@ -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 = '^ !'; diff --git a/src/internal/operators/endWith.ts b/src/internal/operators/endWith.ts index 2619192067..46aa651e3f 100644 --- a/src/internal/operators/endWith.ts +++ b/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 */ @@ -62,5 +63,5 @@ export function endWith(...array: Array): OperatorF * @owner Observable */ export function endWith(...array: Array): MonoTypeOperatorFunction { - return (source: Observable) => concat(source, ...(array as any[])) as Observable; + return (source: Observable) => concat(source, of(...array)) as Observable; }