From e44bf05ce71317217c31f792eb2b6ec4063d581d Mon Sep 17 00:00:00 2001 From: demensky Date: Sat, 21 Jan 2023 00:35:44 +0200 Subject: [PATCH 1/2] feat(concat): removed deprecated `concat` operator BREAKING CHANGE: The `concat` operator is no longer available. Use `concatWith`. --- spec-dtslint/operators/concat-spec.ts | 63 --- spec/Observable-spec.ts | 6 +- spec/observables/fromEvent-spec.ts | 4 +- spec/observables/fromEventPattern-spec.ts | 4 +- spec/observables/interval-spec.ts | 2 +- spec/observables/timer-spec.ts | 4 +- spec/operators/concat-legacy-spec.ts | 362 ------------------ spec/operators/retry-spec.ts | 4 +- src/internal/observable/onErrorResumeNext.ts | 2 +- src/internal/operators/concat.ts | 22 -- src/internal/operators/concatWith.ts | 8 +- .../operators/onErrorResumeNextWith.ts | 2 +- src/operators/index.ts | 1 - 13 files changed, 20 insertions(+), 464 deletions(-) delete mode 100644 spec-dtslint/operators/concat-spec.ts delete mode 100644 spec/operators/concat-legacy-spec.ts delete mode 100644 src/internal/operators/concat.ts diff --git a/spec-dtslint/operators/concat-spec.ts b/spec-dtslint/operators/concat-spec.ts deleted file mode 100644 index 56ebb7ec5e..0000000000 --- a/spec-dtslint/operators/concat-spec.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { of, asyncScheduler } from 'rxjs'; -import { concat } from 'rxjs/operators'; - -it('should infer correctly', () => { - const o = of(1, 2, 3).pipe(concat()); // $ExpectType Observable -}); - -it('should support a scheduler', () => { - const o = of(1, 2, 3).pipe(concat(asyncScheduler)); // $ExpectType Observable -}); - -it('should support one argument', () => { - const o = of(1, 2, 3).pipe(concat(of(1))); // $ExpectType Observable -}); - -it('should support two arguments', () => { - const o = of(1, 2, 3).pipe(concat(of(1), of(2))); // $ExpectType Observable -}); - -it('should support three arguments', () => { - const o = of(1, 2, 3).pipe(concat(of(1), of(2), of(3))); // $ExpectType Observable -}); - -it('should support four arguments', () => { - const o = of(1, 2, 3).pipe(concat(of(1), of(2), of(3), of(4))); // $ExpectType Observable -}); - -it('should support five arguments', () => { - const o = of(1, 2, 3).pipe(concat(of(1), of(2), of(3), of(4), of(5))); // $ExpectType Observable -}); - -it('should support six arguments', () => { - const o = of(1, 2, 3).pipe(concat(of(1), of(2), of(3), of(4), of(5), of(6))); // $ExpectType Observable -}); - -it('should support six or more arguments', () => { - const o = of(1, 2, 3).pipe(concat(of(1), of(2), of(3), of(4), of(5), of(6), of(7), of(8), of(9))); // $ExpectType Observable -}); - -it('should support a scheduler as last parameter', () => { - const o = of(1, 2, 3).pipe(concat(of(4), of(5), of(6), asyncScheduler)); // $ExpectType Observable -}); - -it('should support promises', () => { - const o = of(1, 2, 3).pipe(concat(Promise.resolve(4))); // $ExpectType Observable -}); - -it('should support arrays', () => { - const o = of(1, 2, 3).pipe(concat([4, 5])); // $ExpectType Observable -}); - -it('should support iterables', () => { - const o = of(1, 2, 3).pipe(concat('foo')); // $ExpectType Observable -}); - -it('should infer correctly with multiple types', () => { - const o = of(1, 2, 3).pipe(concat(of('foo'), Promise.resolve([1]), of(6))); // $ExpectType Observable -}); - -it('should enforce types', () => { - const o = of(1, 2, 3).pipe(concat(5)); // $ExpectError - const p = of(1, 2, 3).pipe(concat(of(5), 6)); // $ExpectError -}); diff --git a/spec/Observable-spec.ts b/spec/Observable-spec.ts index a40ca1b0db..aa7a75a94a 100644 --- a/spec/Observable-spec.ts +++ b/spec/Observable-spec.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; import { TeardownLogic } from '../src/internal/types'; import { Observable, config, Subscription, Subscriber, Operator, NEVER, Subject, of, throwError, EMPTY } from 'rxjs'; -import { map, multicast, refCount, filter, count, tap, combineLatestWith, concat, merge, race, zip, catchError, publish, publishLast, publishBehavior, share} from 'rxjs/operators'; +import { map, multicast, refCount, filter, count, tap, combineLatestWith, concatWith, merge, race, zip, catchError, publish, publishLast, publishBehavior, share} from 'rxjs/operators'; import { TestScheduler } from 'rxjs/testing'; import { observableMatcher } from './helpers/observableMatcher'; @@ -1077,13 +1077,13 @@ describe('Observable.lift', () => { }); }); - it('should compose through concat', () => { + it('should compose through concatWith', () => { rxTestScheduler.run(({ cold, expectObservable }) => { const e1 = cold(' --a--b-|'); const e2 = cold(' --x---y--|'); const expected = '--a--b---x---y--|'; - const result = MyCustomObservable.from(e1).pipe(concat(e2, rxTestScheduler)); + const result = MyCustomObservable.from(e1).pipe(concatWith(e2)); expect(result instanceof MyCustomObservable).to.be.true; diff --git a/spec/observables/fromEvent-spec.ts b/spec/observables/fromEvent-spec.ts index 78af118973..81f0576036 100644 --- a/spec/observables/fromEvent-spec.ts +++ b/spec/observables/fromEvent-spec.ts @@ -1,7 +1,7 @@ /** @prettier */ import { expect } from 'chai'; import { fromEvent, NEVER, timer } from 'rxjs'; -import { mapTo, take, concat } from 'rxjs/operators'; +import { mapTo, take, concatWith } from 'rxjs/operators'; import { TestScheduler } from 'rxjs/testing'; import { observableMatcher } from '../helpers/observableMatcher'; @@ -21,7 +21,7 @@ describe('fromEvent', () => { const target = { addEventListener: (eventType: any, listener: any) => { - timer(delay1, delay2).pipe(mapTo('ev'), take(2), concat(NEVER)).subscribe(listener); + timer(delay1, delay2).pipe(mapTo('ev'), take(2), concatWith(NEVER)).subscribe(listener); }, removeEventListener: (): void => void 0, dispatchEvent: (): void => void 0, diff --git a/spec/observables/fromEventPattern-spec.ts b/spec/observables/fromEventPattern-spec.ts index ae80d5f372..a333380b43 100644 --- a/spec/observables/fromEventPattern-spec.ts +++ b/spec/observables/fromEventPattern-spec.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; import { fromEventPattern, noop, NEVER, timer } from 'rxjs'; -import { mapTo, take, concat } from 'rxjs/operators'; +import { mapTo, take, concatWith } from 'rxjs/operators'; import { TestScheduler } from 'rxjs/testing'; import { observableMatcher } from '../helpers/observableMatcher'; @@ -22,7 +22,7 @@ describe('fromEventPattern', () => { const expected = ' -----x-x---'; function addHandler(h: any) { - timer(time1, time2, rxTestScheduler).pipe(mapTo('ev'), take(2), concat(NEVER)).subscribe(h); + timer(time1, time2, rxTestScheduler).pipe(mapTo('ev'), take(2), concatWith(NEVER)).subscribe(h); } const e1 = fromEventPattern(addHandler); diff --git a/spec/observables/interval-spec.ts b/spec/observables/interval-spec.ts index 5e06714881..e5381a1656 100644 --- a/spec/observables/interval-spec.ts +++ b/spec/observables/interval-spec.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import { NEVER, interval, asapScheduler, animationFrameScheduler, queueScheduler } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; -import { take, concat } from 'rxjs/operators'; +import { take } from 'rxjs/operators'; import * as sinon from 'sinon'; import { observableMatcher } from '../helpers/observableMatcher'; diff --git a/spec/observables/timer-spec.ts b/spec/observables/timer-spec.ts index 5c4e69d25c..9837a12910 100644 --- a/spec/observables/timer-spec.ts +++ b/spec/observables/timer-spec.ts @@ -1,6 +1,6 @@ import { timer, NEVER, merge } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; -import { mergeMap, take, concat } from 'rxjs/operators'; +import { mergeMap, take, concatWith } from 'rxjs/operators'; import { observableMatcher } from '../helpers/observableMatcher'; /** @test {timer} */ @@ -15,7 +15,7 @@ describe('timer', () => { rxTest.run(({ expectObservable }) => { const e1 = timer(6, 2, rxTest).pipe( take(4), // make it actually finite, so it can be rendered - concat(NEVER) // but pretend it's infinite by not completing + concatWith(NEVER) // but pretend it's infinite by not completing ); const expected = '------a-b-c-d-'; const values = { diff --git a/spec/operators/concat-legacy-spec.ts b/spec/operators/concat-legacy-spec.ts deleted file mode 100644 index 064b6223b5..0000000000 --- a/spec/operators/concat-legacy-spec.ts +++ /dev/null @@ -1,362 +0,0 @@ -import { expect } from 'chai'; -import { of, Observable } from 'rxjs'; -import { concat, mergeMap } from 'rxjs/operators'; -import { TestScheduler } from 'rxjs/testing'; -import { observableMatcher } from '../helpers/observableMatcher'; - -/** @test {concat} */ -describe('concat operator', () => { - let testScheduler: TestScheduler; - - beforeEach(() => { - testScheduler = new TestScheduler(observableMatcher); - }); - - it('should concatenate two cold observables', () => { - testScheduler.run(({ cold, expectObservable }) => { - const e1 = cold(' --a--b-|'); - const e2 = cold(' --x---y--|'); - const expected = ' --a--b---x---y--|'; - - expectObservable(e1.pipe(concat(e2, testScheduler))).toBe(expected); - }); - }); - - it('should work properly with scalar observables', (done) => { - const results: string[] = []; - - const s1 = new Observable((observer) => { - setTimeout(() => { - observer.next(1); - observer.complete(); - }); - }).pipe(concat(of(2))); - - s1.subscribe({ - next: (x) => { - results.push('Next: ' + x); - }, - error: (x) => { - done(new Error('should not be called')); - }, - complete: () => { - results.push('Completed'); - expect(results).to.deep.equal(['Next: 1', 'Next: 2', 'Completed']); - done(); - }, - }); - }); - - it('should complete without emit if both sources are empty', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' --|'); - const e1subs = ' ^-!'; - const e2 = cold(' ----|'); - const e2subs = ' --^---!'; - const expected = ' ------|'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should not complete if first source does not complete', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' -'); - const e1subs = ' ^'; - const e2 = cold(' --|'); - const e2subs: string[] = []; - const expected = ' -'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should not complete if second source does not complete', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' --|'); - const e1subs = ' ^-!'; - const e2 = cold(' ---'); - const e2subs = ' --^'; - const expected = ' ---'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should not complete if both sources do not complete', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' -'); - const e1subs = ' ^'; - const e2 = cold(' -'); - const e2subs: string[] = []; - const expected = ' -'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should raise error when first source is empty, second source raises error', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' --|'); - const e1subs = ' ^-!'; - const e2 = cold(' ----#'); - const e2subs = ' --^---!'; - const expected = ' ------#'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should raise error when first source raises error, second source is empty', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' ---#'); - const e1subs = ' ^--!'; - const e2 = cold(' ----|'); - const e2subs: string[] = []; - const expected = ' ---#'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should raise first error when both source raise error', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' ---#'); - const e1subs = ' ^--!'; - const e2 = cold(' ------#'); - const e2subs: string[] = []; - const expected = ' ---#'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should concat if first source emits once, second source is empty', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' --a--|'); - const e1subs = ' ^----!'; - const e2 = cold(' --------|'); - const e2subs = ' -----^-------!'; - const expected = ' --a----------|'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should concat if first source is empty, second source emits once', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' --|'); - const e1subs = ' ^-!'; - const e2 = cold(' --a--|'); - const e2subs = ' --^----!'; - const expected = ' ----a--|'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should emit element from first source, and should not complete if second source does not complete', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' --a--|'); - const e1subs = ' ^----!'; - const e2 = cold(' -'); - const e2subs = ' -----^'; - const expected = ' --a---'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should not complete if first source does not complete', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' -'); - const e1subs = ' ^'; - const e2 = cold(' --a--|'); - const e2subs: string[] = []; - const expected = ' -'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should emit elements from each source when source emit once', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' ---a|'); - const e1subs = ' ^---!'; - const e2 = cold(' -----b--|'); - const e2subs = ' ----^-------!'; - const expected = ' ---a-----b--|'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should unsubscribe to inner source if outer is unsubscribed early', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' ---a-a--a| '); - const e1subs = ' ^--------! '; - const e2 = cold(' -----b-b--b-|'); - const e2subs = ' ---------^-------! '; - const unsub = ' -----------------! '; - const expected = ' ---a-a--a-----b-b '; - - expectObservable(e1.pipe(concat(e2)), unsub).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should not break unsubscription chains when result is unsubscribed explicitly', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' ---a-a--a| '); - const e1subs = ' ^--------! '; - const e2 = cold(' -----b-b--b-|'); - const e2subs = ' ---------^-------! '; - const expected = ' ---a-a--a-----b-b- '; - const unsub = ' -----------------! '; - - const result = e1.pipe( - mergeMap((x) => of(x)), - concat(e2), - mergeMap((x) => of(x)) - ); - - expectObservable(result, unsub).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should raise error from first source and does not emit from second source', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' --#'); - const e1subs = ' ^-!'; - const e2 = cold(' ----a--|'); - const e2subs: string[] = []; - const expected = ' --#'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should emit element from first source then raise error from second source', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' --a--|'); - const e1subs = ' ^----!'; - const e2 = cold(' -------#'); - const e2subs = ' -----^------!'; - const expected = ' --a---------#'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should emit all elements from both hot observable sources if first source completes before second source starts emit', () => { - testScheduler.run(({ hot, expectObservable, expectSubscriptions }) => { - const e1 = hot(' --a--b-|'); - const e1subs = ' ^------!'; - const e2 = hot(' --------x--y--|'); - const e2subs = ' -------^------!'; - const expected = '--a--b--x--y--|'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should emit elements from second source regardless of completion time when second source is cold observable', () => { - testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => { - const e1 = hot(' --a--b--c---|'); - const e1subs = ' ^-----------!'; - const e2 = cold(' -x-y-z-|'); - const e2subs = ' ------------^------!'; - const expected = '--a--b--c----x-y-z-|'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should not emit collapsing element from second source', () => { - testScheduler.run(({ hot, expectObservable, expectSubscriptions }) => { - const e1 = hot(' --a--b--c--|'); - const e1subs = ' ^----------!'; - const e2 = hot(' --------x--y--z--|'); - const e2subs = ' -----------^-----!'; - const expected = '--a--b--c--y--z--|'; - - expectObservable(e1.pipe(concat(e2))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - }); - }); - - it('should accept scheduler with multiple observables', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' ---a|'); - const e1subs = ' ^---!'; - const e2 = cold(' ---b--|'); - const e2subs = ' ----^-----!'; - const e3 = cold(' ---c--|'); - const e3subs = ' ----------^-----!'; - const expected = ' ---a---b-----c--|'; - - expectObservable(e1.pipe(concat(e2, e3, testScheduler))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - expectSubscriptions(e2.subscriptions).toBe(e2subs); - expectSubscriptions(e3.subscriptions).toBe(e3subs); - }); - }); - - it('should accept scheduler without observable parameters', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' ---a-|'); - const e1subs = ' ^----!'; - const expected = ' ---a-|'; - - expectObservable(e1.pipe(concat(testScheduler))).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - }); - }); - - it('should emit self without parameters', () => { - testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { - const e1 = cold(' ---a-|'); - const e1subs = ' ^----!'; - const expected = ' ---a-|'; - - expectObservable(e1.pipe(concat())).toBe(expected); - expectSubscriptions(e1.subscriptions).toBe(e1subs); - }); - }); -}); diff --git a/spec/operators/retry-spec.ts b/spec/operators/retry-spec.ts index f5c1dce355..3f2d3eb9f2 100644 --- a/spec/operators/retry-spec.ts +++ b/spec/operators/retry-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { retry, map, take, mergeMap, concat, multicast, refCount } from 'rxjs/operators'; +import { retry, map, take, mergeMap, concatWith, multicast, refCount } from 'rxjs/operators'; import { Observable, Observer, defer, range, of, throwError, Subject, timer, EMPTY } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; import { observableMatcher } from '../helpers/observableMatcher'; @@ -358,7 +358,7 @@ describe('retry', () => { of(1, 2, 3) .pipe( - concat(throwError(() => 'bad!')), + concatWith(throwError(() => 'bad!')), multicast(() => new Subject()), refCount(), retry(4) diff --git a/src/internal/observable/onErrorResumeNext.ts b/src/internal/observable/onErrorResumeNext.ts index ef62c033a1..244f039e08 100644 --- a/src/internal/observable/onErrorResumeNext.ts +++ b/src/internal/observable/onErrorResumeNext.ts @@ -25,7 +25,7 @@ export function onErrorResumeNext(...sources: [... * * If `onErrorResumeNext` is provided no arguments, or a single, empty array, it will return {@link EMPTY}. * - * `onErrorResumeNext` is basically {@link concat}, only it will continue, even if one of its + * `onErrorResumeNext` is basically {@link concatWith}, only it will continue, even if one of its * sources emits an error. * * Note that there is no way to handle any errors thrown by sources via the result of diff --git a/src/internal/operators/concat.ts b/src/internal/operators/concat.ts deleted file mode 100644 index eadb595837..0000000000 --- a/src/internal/operators/concat.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ObservableInputTuple, OperatorFunction, SchedulerLike } from '../types'; -import { operate } from '../util/lift'; -import { concatAll } from './concatAll'; -import { popScheduler } from '../util/args'; -import { from } from '../observable/from'; - -/** @deprecated Replaced with {@link concatWith}. Will be removed in v8. */ -export function concat(...sources: [...ObservableInputTuple]): OperatorFunction; -/** @deprecated Replaced with {@link concatWith}. Will be removed in v8. */ -export function concat( - ...sourcesAndScheduler: [...ObservableInputTuple, SchedulerLike] -): OperatorFunction; - -/** - * @deprecated Replaced with {@link concatWith}. Will be removed in v8. - */ -export function concat(...args: any[]): OperatorFunction { - const scheduler = popScheduler(args); - return operate((source, subscriber) => { - concatAll()(from([source, ...args], scheduler)).subscribe(subscriber); - }); -} diff --git a/src/internal/operators/concatWith.ts b/src/internal/operators/concatWith.ts index b836b29e22..b73afbc5fe 100644 --- a/src/internal/operators/concatWith.ts +++ b/src/internal/operators/concatWith.ts @@ -1,5 +1,7 @@ import { ObservableInputTuple, OperatorFunction } from '../types'; -import { concat } from './concat'; +import { from } from '../observable/from'; +import { concatAll } from '../operators/concatAll'; +import { operate } from '../util/lift'; /** * Emits all of the values from the source observable, then, once it completes, subscribes @@ -44,5 +46,7 @@ import { concat } from './concat'; export function concatWith( ...otherSources: [...ObservableInputTuple] ): OperatorFunction { - return concat(...otherSources); + return operate((source, subscriber) => { + concatAll()(from([source, ...otherSources])).subscribe(subscriber); + }); } diff --git a/src/internal/operators/onErrorResumeNextWith.ts b/src/internal/operators/onErrorResumeNextWith.ts index 9bcac812a4..c67d0a82f8 100644 --- a/src/internal/operators/onErrorResumeNextWith.ts +++ b/src/internal/operators/onErrorResumeNextWith.ts @@ -29,7 +29,7 @@ export function onErrorResumeNextWith( * be happening until there is no more Observables left in the series, at which point returned Observable will * complete - even if the last subscribed stream ended with an error. * - * `onErrorResumeNext` can be therefore thought of as version of {@link concat} operator, which is more permissive + * `onErrorResumeNext` can be therefore thought of as version of {@link concatWith} operator, which is more permissive * when it comes to the errors emitted by its input Observables. While `concat` subscribes to the next Observable * in series only if previous one successfully completed, `onErrorResumeNext` subscribes even if it ended with * an error. diff --git a/src/operators/index.ts b/src/operators/index.ts index 6062dbc39c..61fcd831c9 100644 --- a/src/operators/index.ts +++ b/src/operators/index.ts @@ -10,7 +10,6 @@ export { catchError } from '../internal/operators/catchError'; export { combineAll } from '../internal/operators/combineAll'; export { combineLatestAll } from '../internal/operators/combineLatestAll'; export { combineLatestWith } from '../internal/operators/combineLatestWith'; -export { concat } from '../internal/operators/concat'; export { concatAll } from '../internal/operators/concatAll'; export { concatMap } from '../internal/operators/concatMap'; export { concatMapTo } from '../internal/operators/concatMapTo'; From a7b8b437582e5f73b8d7f8d236f8cfd15b101716 Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Fri, 20 Jan 2023 21:20:52 -0600 Subject: [PATCH 2/2] refactor(concatWith): Use `innerFrom` instead of `from`. --- src/internal/operators/concatWith.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internal/operators/concatWith.ts b/src/internal/operators/concatWith.ts index b73afbc5fe..3a4c657022 100644 --- a/src/internal/operators/concatWith.ts +++ b/src/internal/operators/concatWith.ts @@ -1,5 +1,5 @@ import { ObservableInputTuple, OperatorFunction } from '../types'; -import { from } from '../observable/from'; +import { innerFrom } from '../observable/innerFrom'; import { concatAll } from '../operators/concatAll'; import { operate } from '../util/lift'; @@ -47,6 +47,6 @@ export function concatWith( ...otherSources: [...ObservableInputTuple] ): OperatorFunction { return operate((source, subscriber) => { - concatAll()(from([source, ...otherSources])).subscribe(subscriber); + concatAll()(innerFrom([source, ...otherSources])).subscribe(subscriber); }); }