Skip to content
Permalink
Browse files

fix(endWith): wrap args - they are not observables - in of before con…

…catenating (#4735)

* test(endWith): add failing test

* fix(endWith): wrap args in of before concat

* chore(endWith): remove any assertion
  • Loading branch information...
cartant authored and benlesh committed May 2, 2019
1 parent 7926122 commit 986be2f1a1186cbbd1b2dc68fe6d11ba1f32247e
Showing with 12 additions and 1 deletion.
  1. +10 −0 spec/operators/endWith-spec.ts
  2. +2 −1 src/internal/operators/endWith.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 = '^ !';
@@ -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<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>;
}

1 comment on commit 986be2f

@Brooooooklyn

This comment has been minimized.

Copy link
Contributor

commented on 986be2f May 7, 2019

need a patch version after this fix, or all endWith usage would broken after upgrade to latest RxJS

Please sign in to comment.
You can’t perform that action at this time.