Skip to content

Instantly share code, notes, and snippets.

@ORESoftware
Created January 14, 2017 04:38
Show Gist options
  • Save ORESoftware/5db66d6e80d5ab26f4a25bfe794d5acb to your computer and use it in GitHub Desktop.
Save ORESoftware/5db66d6e80d5ab26f4a25bfe794d5acb to your computer and use it in GitHub Desktop.
Basic Promise vs. Observable
const {Observable} = require('rxjs');
function makeObs(){
const obs = Observable.create(sub => {
setTimeout(() => {
sub.next(3);
},500);
});
.
obs = obs.flatMap(() => {
return someOtherObservable()
});
return obs;
}
function promiseProvider(){
const promise = new Promise((resolve,reject) => {
setTimeout(() => {
resolve(3);
},500);
});
.
promise = promise.then(() => {
return someOtherPromise()
});
return promise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment