Last active
February 21, 2022 22:57
-
-
Save EnricoPicci/a5b225bb645b072e6e87debb9304cfa9 to your computer and use it in GitHub Desktop.
This file contains 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
// example of how to use bufferConcatMap | |
import { delay, interval, of, take } from 'rxjs'; | |
import { bufferConcatMap } from './bufferedConcatMap'; | |
// source Observable | |
const source = interval(100).pipe(take(5)); | |
// new transformed Observable created with bufferConcatMap | |
// this is when bufferConcatMap is actually invoked | |
const newTransformedObs = source.pipe(bufferConcatMap((n) => of(n).pipe(delay(1000)))); | |
// subscribe the new Observable | |
// it is only at subscription time, i.e. here, that the Pipeable Operator, | |
// i.e. the function returned by bufferConcatMap, is actually invoked | |
newTransformedObs.subscribe(console.log); | |
// prints: [0], [1,2,3,4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment