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

docs(operators): Add a simple example in doc string #4636

Merged
merged 4 commits into from
Mar 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/internal/operators/switchMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ export function switchMap<T, R, O extends ObservableInput<any>>(project: (value:
* subsequent inner Observables.
*
* ## Example
* Generate new Observable according to source Observable values
* ```typescript
* import { of } from 'rxjs';
* import { switchMap } from 'rxjs/operators';
*
* const switched = of(1, 2, 3).pipe(switchMap((x: number) => of(x, x ** 2, x ** 3)));
* switched.subscribe(x => console.log(x));
* // outputs
* // 1
* // 1
* // 2
* // 4
* // 8
* // ... and so on
* ```
*
xuemind marked this conversation as resolved.
Show resolved Hide resolved
* Rerun an interval Observable on every click event
* ```javascript
* import { fromEvent, interval } from 'rxjs';
Expand Down