Last active
February 28, 2019 12:29
-
-
Save kosich/0bae1cf4f1efa4db0ad0ae0d57d025d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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