Skip to content

Instantly share code, notes, and snippets.

@kosich
Created April 20, 2019 20:37
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 kosich/a69f909dbb8dfe43e459beaa1a004d18 to your computer and use it in GitHub Desktop.
Save kosich/a69f909dbb8dfe43e459beaa1a004d18 to your computer and use it in GitHub Desktop.
const { rxObserver } = require('api/v0.3');
const { timer, from, of, EMPTY } = require('rxjs');
const { zip, debounceTime, map, scan, distinctUntilChanged } = require('rxjs/operators');
// create a source using values
const values$ = from([ 5, 10, 20, 10, 5, 20, 0, 5, 30 ]);
const source$ = timer(0, 10).pipe(
zip(values$, (_,x)=>x)
);
const result$ = source$.pipe(
map(e => e),
scan((prev, curr) => Math.max(prev, curr), 0),
distinctUntilChanged()
);
source$.subscribe(rxObserver('source$'));
result$.subscribe(rxObserver('result$'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment