Skip to content

Instantly share code, notes, and snippets.

@colwem
Last active April 22, 2016 20:44
Show Gist options
  • Save colwem/93269da273657fc62208333fe307d2db to your computer and use it in GitHub Desktop.
Save colwem/93269da273657fc62208333fe307d2db to your computer and use it in GitHub Desktop.
using rx.js queries with promises
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