Skip to content

Instantly share code, notes, and snippets.

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