Last active
April 22, 2016 20:44
-
-
Save colwem/93269da273657fc62208333fe307d2db to your computer and use it in GitHub Desktop.
using rx.js queries with promises
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
let value = 20; | |
Rx.Observable.defer(() => { | |
return Rx.Observable.fromPromise(Promise.try(() => { | |
console.log('test/rx.js: 16'); | |
console.log(value); | |
return value -= 1; | |
})); | |
}) | |
.repeat() | |
.takeWhile(() => { | |
return Promise.try(() => { | |
console.log('test/rx.js: 22'); | |
console.log(value); | |
return value > 10; | |
}); | |
}) | |
.subscribe( | |
(val) => { | |
console.log('test/rx.js: 31'); | |
console.log(val); | |
}, | |
(err) => { | |
console.log(err.stack); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment