Skip to content

Instantly share code, notes, and snippets.

@webhacking
Created January 24, 2019 04:55
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 webhacking/f456c1cc8bc7690f794022f3c5a18453 to your computer and use it in GitHub Desktop.
Save webhacking/f456c1cc8bc7690f794022f3c5a18453 to your computer and use it in GitHub Desktop.
RxJS Example 03
import {fromEvent} from 'rxjs/internal/observable/fromEvent';
import {interval} from 'rxjs/internal/observable/interval';
import {buffer, filter, map} from 'rxjs/operators';
let stream$ = fromEvent(document.getElementById('hit-me') as HTMLElement, 'click');
stream$
.pipe(
buffer(interval(3000)),
map((val: number[]) => val.length),
filter((x: number) => x > 1)
)
.subscribe((val: number) => {
console.log(val)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment