Created
January 14, 2017 04:38
-
-
Save ORESoftware/5db66d6e80d5ab26f4a25bfe794d5acb to your computer and use it in GitHub Desktop.
Basic Promise vs. Observable
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 {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