Skip to content

Commit 986be2f

Browse files
cartantbenlesh
authored andcommittedMay 2, 2019
fix(endWith): wrap args - they are not observables - in of before concatenating (#4735)
* test(endWith): add failing test * fix(endWith): wrap args in of before concat * chore(endWith): remove any assertion
1 parent 7926122 commit 986be2f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎spec/operators/endWith-spec.ts

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ describe('endWith operator', () => {
2020
expectSubscriptions(e1.subscriptions).toBe(e1subs);
2121
});
2222

23+
it('should append numbers to a cold Observable', () => {
24+
const values = { a: 1, b: 2, c: 3, s: 4 };
25+
const e1 = cold('---a--b--c--|', values);
26+
const e1subs = '^ !';
27+
const expected = '---a--b--c--(s|)';
28+
29+
expectObservable(e1.pipe(endWith(values.s))).toBe(expected, values);
30+
expectSubscriptions(e1.subscriptions).toBe(e1subs);
31+
});
32+
2333
it('should end an observable with given value', () => {
2434
const e1 = hot('--a--|');
2535
const e1subs = '^ !';

‎src/internal/operators/endWith.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Observable } from '../Observable';
22
import { concat } from '../observable/concat';
3+
import { of } from '../observable/of';
34
import { MonoTypeOperatorFunction, SchedulerLike, OperatorFunction } from '../types';
45

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

1 commit comments

Comments
 (1)

Brooooooklyn commented on May 7, 2019

@Brooooooklyn
Contributor

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

Please sign in to comment.