Last active
April 19, 2018 15:32
-
-
Save edulan/198ce1868ccd19ed7194c3b4d67dbd2b to your computer and use it in GitHub Desktop.
Rx photobooth, take 4 photos with a 5 seconds countdown between them
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 takePhoto = () => new Promise((resolve) => (setTimeout(resolve, Math.random() * 1E3 + 5E2, 'photo'))) | |
const makeCountdown = (seconds) => | |
Rx.Observable | |
.concat( | |
Rx.Observable | |
.interval(1E3) | |
.take(seconds), | |
Rx.Observable.defer(() => takePhoto()) | |
) | |
Rx.Observable | |
.range(1, 4) | |
.concatMap(() => makeCountdown(5)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment