Created
September 4, 2019 10:57
-
-
Save micha149/043f0db38e15813d9c1f0d087336864f to your computer and use it in GitHub Desktop.
Buffered RXJS
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
const { rxObserver } = require('api/v0.3'); | |
const { interval, from, timer, of } = require('rxjs'); | |
const { take, bufferCount, concatMap, delay, first, mergeMap, map, throttleTime, ignoreElements, startWith } = require('rxjs/operators'); | |
const spaceTime = time => concatMap(value => | |
of(value).pipe( | |
delay(time) | |
) | |
); | |
interval(10).pipe( | |
take(10), | |
bufferCount(3), | |
mergeMap(counts => { | |
const chars = counts.map(num => String.fromCharCode(65 + num)); | |
return from(chars); | |
}), | |
spaceTime(5), | |
).subscribe(rxObserver()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment