-
Notifications
You must be signed in to change notification settings - Fork 3k
[docs]: Create Deprecation page per deprecation group #5426
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
Merged
cartant
merged 5 commits into
ReactiveX:master
from
niklas-wortmann:feature/doc-deprecations
Sep 24, 2020
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
60d1d35
docs(deprecation): init deprecation section
niklas-wortmann 19618d1
docs(deprecations): add scheduler deprecation page and adjust depreca…
niklas-wortmann 5e67b10
docs(deprecations): remove jsdoc style from deprecation message
niklas-wortmann 633b9b2
chore: fix typos
cartant dc2ccc3
chore: make changes to address my comments
cartant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Scheduler Argument | ||
|
||
To limit the API surface of some operators, but also prepare for a [major refactoring in V8](https://github.com/ReactiveX/rxjs/pull/4583), we | ||
agreed on deprecating the `scheduler` argument from many operators. It solely deprecates those methods where this argument is rarely used. So `time` related | ||
operators, like [`interval`](https://rxjs.dev/api/index/function/interval) are not affected by this deprecation. | ||
|
||
To support this transition the [scheduled creation function](/api/index/function/scheduled) was added. | ||
|
||
<div class="alert is-important"> | ||
<span> | ||
This deprecation was introduced in **RxJS 6.5** and will become breaking with **RxJS 8**. | ||
</span> | ||
</div> | ||
|
||
## Operators affected by this Change | ||
|
||
- [from](/api/index/function/from) | ||
- [of](/api/index/function/of) | ||
- [merge](/api/index/function/merge) | ||
- [concat](/api/index/function/concat) | ||
- [startWith](/api/operators/startWith) | ||
- [endWith](/api/operators/endWith) | ||
- [combineLatest](/api/index/function/combineLatest) | ||
|
||
## How to Refactor | ||
|
||
If you use any other operator from the list a 8000 bove and using the `scheduler` argument, you have to three potential refactoring options. | ||
|
||
### Refactoring of `of` and `from` | ||
|
||
`scheduled` is kinda copying the behavior of `from`. Therefore if you used `from` with a `scheduler` argument, you can just replace them. | ||
|
||
For the `of` creation function you need to this Observable with `scheduled` and instead of passing the `scheduler` argument to `of` pass it to `scheduled`. | ||
Following code example demonstrate this process. | ||
|
||
```ts | ||
import { of, asyncScheduler, scheduled } from 'rxjs'; | ||
|
||
// Deprecated approach | ||
of([1,2,3], asyncScheduler).subscribe(x => console.log(x)); | ||
// suggested approach | ||
scheduled([1,2,3], asyncScheduler).subscribe(x => console.log(x)); | ||
``` | ||
|
||
### Refactoring of `merge`, `concat`, `combineLatest`, `startWith` and `endWith` | ||
|
||
In case you used to pass a scheduler argument to one of these operators you probably had code like this: | ||
|
||
```ts | ||
import { concat, of, asyncScheduler } from 'rxjs'; | ||
|
||
concat( | ||
of('hello '), | ||
of('World'), | ||
asyncScheduler | ||
).subscribe(x => console.log(x)); | ||
``` | ||
|
||
To work around this deprecation you can leverage the [`scheduled`](/api/index/function/scheduled) function. | ||
|
||
```ts | ||
import { scheduled, of, asyncScheduler } from 'rxjs'; | ||
import { concatAll } from 'rxjs/operators' | ||
|
||
scheduled( | ||
[of('hello '), of('World')], | ||
asyncScheduler | ||
).pipe( | ||
concatAll() | ||
).subscribe(x => console.log(x)); | ||
``` | ||
|
||
You can apply this pattern to refactor deprecated usage of `concat`, `startWith` and `endWith` but do notice that you will want to use [mergeAll](/api/operators/mergeAll) to refactor the deprecated usage of `merge`. | ||
|
||
With `combineLatest`, you will want to use [combineAll](/api/operators/combineAll) | ||
|
||
E.g. code that used to look like this: | ||
|
||
```ts | ||
import { combineLatest, of, asyncScheduler } from 'rxjs'; | ||
|
||
combineLatest( | ||
of('hello '), | ||
of('World'), | ||
asyncScheduler | ||
).subscribe(console.log) | ||
``` | ||
|
||
would become: | ||
|
||
```ts | ||
import { scheduled, of, asyncScheduler } from 'rxjs'; | ||
import { combineAll } from 'rxjs/operators' | ||
|
||
scheduled( | ||
[of('hello '), of('World')], | ||
asyncScheduler | ||
).pipe( | ||
combineAll() | ||
).subscribe(x => console.log(x)); | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Higher-order Observables | ||
|
||
Observables most commonly emit ordinary values like strings and numbers, but surprisingly often, it is necessary to handle Observables *of* Observables, so-called higher-order Observables. For example, imagine you have an Observable emitting strings that are the URLs of files you want to fetch. The code might look like this: | ||
|
||
```ts | ||
const fileObservable = urlObservable.pipe( | ||
map(url => http.get(url)), | ||
); | ||
``` | ||
|
||
`http.get()` returns an Observable for each URL. Now you have an Observable *of* Observables, a higher-order Observable. | ||
|
||
But how do you work with a higher-order Observable? Typically, by _flattening_: by converting a higher-order Observable into an ordinary Observable. For example: | ||
|
||
```ts | ||
const fileObservable = urlObservable.pipe( | ||
concatMap(url => http.get(url)), | ||
); | ||
``` | ||
|
||
The Observable returned in the `concatMap` function is usually referred to as a so-called "inner" Observable, while in this context the `urlObservable` is the so-called "outer" Observable. | ||
|
||
The [`concatMap()`](/api/operators/concatMap) operator subscribes to each "inner" Observable, buffers all further emissions of the "outer" Observable, and copies all the emitted values until the inner Observable completes, and continues processing the values of the "outer Observable". All of the values are in that way concatenated. Other useful flattening operators are | ||
|
||
* [`mergeMap()`](/api/operators/mergeMap) — subscribes to each inner Observable as it arrives, then emits each value as it arrives | ||
cartant marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* [`switchMap()`](/api/operators/switchMap) — subscribes to the first inner Observable when it arrives, and emits each value as it arrives, but when the next inner Observable arrives, unsubscribes to the previous one, and subscribes to the new one. | ||
* [`exhaustMap()`](/api/operators/exhaustMap) — subscribes to the first inner Observable when it arrives, and emits each value as it arrives, discarding all newly arriving inner Observables until that first one completes, then waits for the next inner Observable. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.