Skip to content

Commit

Permalink
docs(share): use tap for logging in share example
Browse files Browse the repository at this point in the history
  • Loading branch information
jakovljevic-mladen committed Dec 7, 2021
1 parent 7ebbbfa commit df209af
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/internal/operators/share.ts
Expand Up @@ -72,34 +72,37 @@ export function share<T>(options: ShareConfig<T>): MonoTypeOperatorFunction<T>;
* Generate new multicast Observable from the `source` Observable value
*
* ```ts
* import { interval, map, share } from 'rxjs';
* import { interval, tap, map, take, share } from 'rxjs';
*
* const source = interval(1000)
* .pipe(
* map((x: number) => {
* console.log('Processing: ', x);
* return x*x;
* }),
* share()
* const source = interval(1000).pipe(
* tap(x => console.log('Processing: ', x)),
* map(x => x * x),
* take(6),
* share()
* );
*
* source.subscribe(x => console.log('subscription 1: ', x));
* source.subscribe(x => console.log('subscription 2: ', x));
*
* // Logs:
* // Processing: 0
* // subscription 1: 0
* // subscription 2: 0
* // Processing: 1
* // subscription 1: 1
* // subscription 2: 1
* // Processing: 2
* // subscription 1: 4
* // subscription 2: 4
* // Processing: 3
* // subscription 1: 9
* // subscription 2: 9
* // ... and so on
* // Processing: 0
* // subscription 1: 0
* // subscription 2: 0
* // Processing: 1
* // subscription 1: 1
* // subscription 2: 1
* // Processing: 2
* // subscription 1: 4
* // subscription 2: 4
* // Processing: 3
* // subscription 1: 9
* // subscription 2: 9
* // Processing: 4
* // subscription 1: 16
* // subscription 2: 16
* // Processing: 5
* // subscription 1: 25
* // subscription 2: 25
* ```
*
* ## Example with notifier factory: Delayed reset
Expand Down

0 comments on commit df209af

Please sign in to comment.