Skip to content

Instantly share code, notes, and snippets.

@kosich
Last active February 28, 2019 12:29
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/0bae1cf4f1efa4db0ad0ae0d57d025d6 to your computer and use it in GitHub Desktop.
Save kosich/0bae1cf4f1efa4db0ad0ae0d57d025d6 to your computer and use it in GitHub Desktop.
const { rxObserver } = require('api/v0.3');
const { timer, Subject } = require('rxjs');
const { tap, take, takeUntil, map } = require('rxjs/operators');
const userClick = new Subject();
let counter = 5;
let tick = 10;
timer(0, tick)
.pipe(
take(counter + 1),
map(value => counter - value),
tap(value => {
if (value === 0) {
console.log('OUT OF TIME');
}
}),
takeUntil(userClick)
)
.subscribe(rxObserver('timer(10)'));
// setTimeout(()=>{
// userClick.next(void 0);
// }, 30);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment