Skip to content

Instantly share code, notes, and snippets.

@micha149
Created September 4, 2019 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micha149/043f0db38e15813d9c1f0d087336864f to your computer and use it in GitHub Desktop.
Save micha149/043f0db38e15813d9c1f0d087336864f to your computer and use it in GitHub Desktop.
Buffered RXJS
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