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

Removed deprecated symbols that have a new name #7164

Merged
merged 10 commits into from
Jan 24, 2023
1 change: 0 additions & 1 deletion docs_app/content/guide/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ These are Observable creation operators that also have join functionality -- emi
- [`bufferWhen`](/api/operators/bufferWhen)
- [`concatMap`](/api/operators/concatMap)
- [`concatMapTo`](/api/operators/concatMapTo)
- [`exhaust`](/api/operators/exhaust)
- [`exhaustMap`](/api/operators/exhaustMap)
- [`expand`](/api/operators/expand)
- [`groupBy`](/api/operators/groupBy)
Expand Down
10 changes: 5 additions & 5 deletions docs_app/content/guide/scheduler.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<span class="informal">A Scheduler lets you define in what execution context will an Observable deliver notifications to its Observer.</span>

In the example below, we take the usual simple Observable that emits values `1`, `2`, `3` synchronously, and use the operator `observeOn` to specify the `async` scheduler to use for delivering those values.
In the example below, we take the usual simple Observable that emits values `1`, `2`, `3` synchronously, and use the operator `observeOn` to specify the `asyncScheduler` scheduler to use for delivering those values.

<!-- prettier-ignore -->
```ts
Expand Down Expand Up @@ -98,13 +98,13 @@ const proxyObserver = {
};
```

The `async` Scheduler operates with a `setTimeout` or `setInterval`, even if the given `delay` was zero. As usual, in JavaScript, `setTimeout(fn, 0)` is known to run the function `fn` earliest on the next event loop iteration. This explains why `got value 1` is delivered to the `finalObserver` after `just after subscribe` happened.
The `asyncScheduler` Scheduler operates with a `setTimeout` or `setInterval`, even if the given `delay` was zero. As usual, in JavaScript, `setTimeout(fn, 0)` is known to run the function `fn` earliest on the next event loop iteration. This explains why `got value 1` is delivered to the `finalObserver` after `just after subscribe` happened.

The `schedule()` method of a Scheduler takes a `delay` argument, which refers to a quantity of time relative to the Scheduler's own internal clock. A Scheduler's clock need not have any relation to the actual wall-clock time. This is how temporal operators like `delay` operate not on actual time, but on time dictated by the Scheduler's clock. This is specially useful in testing, where a _virtual time Scheduler_ may be used to fake wall-clock time while in reality executing scheduled tasks synchronously.

## Scheduler Types

The `async` Scheduler is one of the built-in schedulers provided by RxJS. Each of these can be created and returned by using static properties of the `Scheduler` object.
The `asyncScheduler` Scheduler is one of the built-in schedulers provided by RxJS. Each of these can be created and returned by using static properties of the `Scheduler` object.

| Scheduler | Purpose |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
Expand All @@ -116,7 +116,7 @@ The `async` Scheduler is one of the built-in schedulers provided by RxJS. Each o

## Using Schedulers

You may have already used schedulers in your RxJS code without explicitly stating the type of schedulers to be used. This is because all Observable operators that deal with concurrency have optional schedulers. If you do not provide the scheduler, RxJS will pick a default scheduler by using the principle of least concurrency. This means that the scheduler which introduces the least amount of concurrency that satisfies the needs of the operator is chosen. For example, for operators returning an observable with a finite and small number of messages, RxJS uses no Scheduler, i.e. `null` or `undefined`. For operators returning a potentially large or infinite number of messages, `queue` Scheduler is used. For operators which use timers, `async` is used.
You may have already used schedulers in your RxJS code without explicitly stating the type of schedulers to be used. This is because all Observable operators that deal with concurrency have optional schedulers. If you do not provide the scheduler, RxJS will pick a default scheduler by using the principle of least concurrency. This means that the scheduler which introduces the least amount of concurrency that satisfies the needs of the operator is chosen. For example, for operators returning an observable with a finite and small number of messages, RxJS uses no Scheduler, i.e. `null` or `undefined`. For operators returning a potentially large or infinite number of messages, `queueScheduler` Scheduler is used. For operators which use timers, `asyncScheduler` is used.

Because RxJS uses the least concurrency scheduler, you can pick a different scheduler if you want to introduce concurrency for performance purpose. To specify a particular scheduler, you can use those operator methods that take a scheduler, e.g., `from([10, 20, 30], asyncScheduler)`.

Expand Down Expand Up @@ -146,4 +146,4 @@ Time-related operators like `bufferTime`, `debounceTime`, `delay`, `auditTime`,

Other instance operators that take a Scheduler as argument: `cache`, `combineLatest`, `concat`, `expand`, `merge`, `publishReplay`, `startWith`.

Notice that both `cache` and `publishReplay` accept a Scheduler because they utilize a ReplaySubject. The constructor of a ReplaySubjects takes an optional Scheduler as the last argument because ReplaySubject may deal with time, which only makes sense in the context of a Scheduler. By default, a ReplaySubject uses the `queue` Scheduler to provide a clock.
Notice that both `cache` and `publishReplay` accept a Scheduler because they utilize a ReplaySubject. The constructor of a ReplaySubjects takes an optional Scheduler as the last argument because ReplaySubject may deal with time, which only makes sense in the context of a Scheduler. By default, a ReplaySubject uses the `queueScheduler` Scheduler to provide a clock.
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
import { of } from 'rxjs';
import { onErrorResumeNext } from 'rxjs/operators';
import { onErrorResumeNextWith } from 'rxjs/operators';

it('should infer correctly', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext()); // $ExpectType Observable<string>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith()); // $ExpectType Observable<string>
});

it('should accept one input', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(of(1))); // $ExpectType Observable<string | number>
const p = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(of('5'))); // $ExpectType Observable<string>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith(of(1))); // $ExpectType Observable<string | number>
const p = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith(of('5'))); // $ExpectType Observable<string>
});

it('should accept promises', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(Promise.resolve(5))); // $ExpectType Observable<string | number>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith(Promise.resolve(5))); // $ExpectType Observable<string | number>
});

it('should accept iterables', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext('foo')); // $ExpectType Observable<string>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith('foo')); // $ExpectType Observable<string>
});

it('should accept arrays', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext([5])); // $ExpectType Observable<string | number>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith([5])); // $ExpectType Observable<string | number>
});

it('should accept two inputs', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(of(1), of(2))); // $ExpectType Observable<string | number>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith(of(1), of(2))); // $ExpectType Observable<string | number>
});

it('should accept three inputs', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(of(1), of(2), of('3'))); // $ExpectType Observable<string | number>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith(of(1), of(2), of('3'))); // $ExpectType Observable<string | number>
});

it('should accept four inputs', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(of(1), of(2), of('3'), of('4'))); // $ExpectType Observable<string | number>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith(of(1), of(2), of('3'), of('4'))); // $ExpectType Observable<string | number>
});

it('should accept five inputs', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(of(1), of(2), of('3'), of('4'), of(5))); // $ExpectType Observable<string | number>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith(of(1), of(2), of('3'), of('4'), of(5))); // $ExpectType Observable<string | number>
});

it('should accept six inputs', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(of(1), of(2), of('3'), of('4'), of(5), of('6'))); // $ExpectType Observable<string | number>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith(of(1), of(2), of('3'), of('4'), of(5), of('6'))); // $ExpectType Observable<string | number>
});

it('should accept seven and more inputs', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(of(1), of(2), of('3'), of('4'), of(5), of('6'), of(7))); // $ExpectType Observable<string | number>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith(of(1), of(2), of('3'), of('4'), of(5), of('6'), of(7))); // $ExpectType Observable<string | number>
});

it('should enforce types', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(5)); // $ExpectError
});
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNextWith(5)); // $ExpectError
});
2 changes: 1 addition & 1 deletion spec/helpers/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (!(Symbol as any).observable) {
(Symbol as any).observable = Symbol('Symbol.observable polyfill from RxJS Testing');
}

/** Polyfill requestAnimationFrame for testing animationFrame scheduler in Node */
/** Polyfill requestAnimationFrame for testing animationFrameScheduler scheduler in Node */
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating

Expand Down
3 changes: 0 additions & 3 deletions spec/index-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ describe('index', () => {
expect(index.bufferToggle).to.exist;
expect(index.bufferWhen).to.exist;
expect(index.catchError).to.exist;
expect(index.combineAll).to.exist;
expect(index.combineLatestAll).to.exist;
expect(index.combineLatestWith).to.exist;
expect(index.concatAll).to.exist;
Expand All @@ -105,7 +104,6 @@ describe('index', () => {
expect(index.elementAt).to.exist;
expect(index.endWith).to.exist;
expect(index.every).to.exist;
expect(index.exhaust).to.exist;
expect(index.exhaustAll).to.exist;
expect(index.exhaustMap).to.exist;
expect(index.expand).to.exist;
Expand All @@ -123,7 +121,6 @@ describe('index', () => {
expect(index.materialize).to.exist;
expect(index.max).to.exist;
expect(index.mergeAll).to.exist;
expect(index.flatMap).to.exist;
expect(index.mergeMap).to.exist;
expect(index.mergeMapTo).to.exist;
expect(index.mergeScan).to.exist;
Expand Down
4 changes: 2 additions & 2 deletions spec/operators/exhaustAll-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { TestScheduler } from 'rxjs/testing';
import { of, Observable } from 'rxjs';
import { observableMatcher } from '../helpers/observableMatcher';

/** @test {exhaust} */
describe('exhaust', () => {
/** @test {exhaustAll} */
describe('exhaustAll', () => {
let testScheduler: TestScheduler;

beforeEach(() => {
Expand Down
3 changes: 0 additions & 3 deletions spec/operators/index-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('operators/index', () => {
expect(index.bufferToggle).to.exist;
expect(index.bufferWhen).to.exist;
expect(index.catchError).to.exist;
expect(index.combineAll).to.exist;
expect(index.combineLatestAll).to.exist;
expect(index.concatAll).to.exist;
expect(index.concatMap).to.exist;
Expand All @@ -28,7 +27,6 @@ describe('operators/index', () => {
expect(index.distinctUntilKeyChanged).to.exist;
expect(index.elementAt).to.exist;
expect(index.every).to.exist;
expect(index.exhaust).to.exist;
expect(index.exhaustAll).to.exist;
expect(index.exhaustMap).to.exist;
expect(index.expand).to.exist;
Expand All @@ -47,7 +45,6 @@ describe('operators/index', () => {
expect(index.max).to.exist;
expect(index.mergeAll).to.exist;
expect(index.mergeMap).to.exist;
expect(index.flatMap).to.exist;
expect(index.mergeMap).to.exist;
expect(index.mergeMapTo).to.exist;
expect(index.mergeScan).to.exist;
Expand Down
34 changes: 17 additions & 17 deletions spec/operators/onErrorResumeNext-spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expect } from 'chai';
import { TestScheduler } from 'rxjs/testing';
import { onErrorResumeNext, take, finalize, tap } from 'rxjs/operators';
import { onErrorResumeNextWith, take, finalize, tap } from 'rxjs/operators';
import { concat, throwError, of, Observable } from 'rxjs';
import { asInteropObservable } from '../helpers/interop-helper';
import { observableMatcher } from '../helpers/observableMatcher';

describe('onErrorResumeNext', () => {
describe('onErrorResumeNextWith', () => {
let testScheduler: TestScheduler;

beforeEach(() => {
Expand All @@ -20,7 +20,7 @@ describe('onErrorResumeNext', () => {
const e2subs = ' --------^-------!';
const expected = '--a--b----c--d--|';

expectObservable(e1.pipe(onErrorResumeNext(e2))).toBe(expected);
expectObservable(e1.pipe(onErrorResumeNextWith(e2))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});
Expand All @@ -34,7 +34,7 @@ describe('onErrorResumeNext', () => {
const e2subs = ' --------^-------!';
const expected = '--a--b----c--d--|';

expectObservable(e1.pipe(onErrorResumeNext(e2))).toBe(expected);
expectObservable(e1.pipe(onErrorResumeNextWith(e2))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});
Expand All @@ -56,7 +56,7 @@ describe('onErrorResumeNext', () => {
];
const expected = '--a--b----c--d----e----f--g--|';

expectObservable(e1.pipe(onErrorResumeNext(e2))).toBe(expected);
expectObservable(e1.pipe(onErrorResumeNextWith(e2))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2[0].subscriptions).toBe(e2subs[0]);
expectSubscriptions(e2[1].subscriptions).toBe(e2subs[1]);
Expand All @@ -76,7 +76,7 @@ describe('onErrorResumeNext', () => {
const e4subs = ' ---------------------^-------!';
const expected = '--a--b----c--d----e----f--g--|';

expectObservable(e1.pipe(onErrorResumeNext(e2, e3, e4))).toBe(expected);
expectObservable(e1.pipe(onErrorResumeNextWith(e2, e3, e4))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
expectSubscriptions(e3.subscriptions).toBe(e3subs);
Expand All @@ -96,7 +96,7 @@ describe('onErrorResumeNext', () => {
const e4subs = ' ---------------------^-------!';
const expected = '--a--b----c--d----e----f--g--|';

expectObservable(e1.pipe(onErrorResumeNext(e2, e3, e4))).toBe(expected);
expectObservable(e1.pipe(onErrorResumeNextWith(e2, e3, e4))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
expectSubscriptions(e3.subscriptions).toBe(e3subs);
Expand All @@ -116,7 +116,7 @@ describe('onErrorResumeNext', () => {
const e4subs = ' -------------^-------!';
const expected = '--c--d----e----f--g--|';

expectObservable(e1.pipe(onErrorResumeNext(e2, e3, e4))).toBe(expected);
expectObservable(e1.pipe(onErrorResumeNextWith(e2, e3, e4))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
expectSubscriptions(e3.subscriptions).toBe(e3subs);
Expand All @@ -132,7 +132,7 @@ describe('onErrorResumeNext', () => {
const e2subs = ' --------^-';
const expected = '--a--b----';

expectObservable(e1.pipe(onErrorResumeNext(e2))).toBe(expected);
expectObservable(e1.pipe(onErrorResumeNextWith(e2))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});
Expand All @@ -146,7 +146,7 @@ describe('onErrorResumeNext', () => {
const e2subs: string[] = [];
const expected = '--a--';

expectObservable(e1.pipe(onErrorResumeNext(e2))).toBe(expected);
expectObservable(e1.pipe(onErrorResumeNextWith(e2))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});
Expand All @@ -160,7 +160,7 @@ describe('onErrorResumeNext', () => {
const e2subs = ' --------^-------!';
const expected = '--a--b----c--d--|';

expectObservable(e1.pipe(onErrorResumeNext(e2))).toBe(expected);
expectObservable(e1.pipe(onErrorResumeNextWith(e2))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});
Expand All @@ -178,7 +178,7 @@ describe('onErrorResumeNext', () => {
});

throwError(() => new Error('Some error'))
.pipe(onErrorResumeNext(synchronousObservable), take(3))
.pipe(onErrorResumeNextWith(synchronousObservable), take(3))
.subscribe(() => {
/* noop */
});
Expand All @@ -201,7 +201,7 @@ describe('onErrorResumeNext', () => {
// test ensures that unsubscriptions are chained all the way to the
// interop subscriber.

expectObservable(e1.pipe(onErrorResumeNext(asInteropObservable(e2))), unsub).toBe(expected);
expectObservable(e1.pipe(onErrorResumeNextWith(asInteropObservable(e2))), unsub).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});
Expand All @@ -214,7 +214,7 @@ describe('onErrorResumeNext', () => {
throwError(() => 'meh')
);

source.pipe(onErrorResumeNext(Promise.resolve(2))).subscribe({
source.pipe(onErrorResumeNextWith(Promise.resolve(2))).subscribe({
next: (x) => {
expect(expected.shift()).to.equal(x);
},
Expand All @@ -232,7 +232,7 @@ describe('onErrorResumeNext', () => {
const results: any[] = [];

of(1)
.pipe(onErrorResumeNext([2, 3, 4], { notValid: 'LOL' } as any, of(5, 6)))
.pipe(onErrorResumeNextWith([2, 3, 4], { notValid: 'LOL' } as any, of(5, 6)))
.subscribe({
next: (value) => results.push(value),
complete: () => results.push('complete'),
Expand All @@ -247,7 +247,7 @@ describe('onErrorResumeNext', () => {
of(1)
.pipe(
finalize(() => results.push('finalize 1')),
onErrorResumeNext(
onErrorResumeNextWith(
of(2).pipe(finalize(() => results.push('finalize 2'))),
of(3).pipe(finalize(() => results.push('finalize 3'))),
of(4).pipe(finalize(() => results.push('finalize 4')))
Expand All @@ -270,7 +270,7 @@ describe('onErrorResumeNext', () => {
subscribe: () => results.push('subscribe 1'),
finalize: () => results.push('finalize 1'),
}),
onErrorResumeNext(
onErrorResumeNextWith(
of(2).pipe(
tap({
subscribe: () => results.push('subscribe 2'),
Expand Down
4 changes: 2 additions & 2 deletions spec/operators/share-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
map,
mergeMap,
mergeMapTo,
onErrorResumeNext,
onErrorResumeNextWith,
repeat,
retry,
share,
Expand Down Expand Up @@ -906,7 +906,7 @@ describe('share', () => {

const sharedSource = source.pipe(share({ resetOnError: () => reset, resetOnRefCountZero }));

const result = concat(sharedSource.pipe(onErrorResumeNext(firstPause)), sharedSource);
const result = concat(sharedSource.pipe(onErrorResumeNextWith(firstPause)), sharedSource);

expectObservable(result, subscription).toBe(expected);
expectSubscriptions(source.subscriptions).toBe(sourceSubs);
Expand Down
Loading