Last active
August 29, 2017 14:00
-
-
Save Kamisama666/54dc36ea40074f9a5a4b59f04a907724 to your computer and use it in GitHub Desktop.
Method to reduce an RxJs Observable to a Promise.
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 Q = require('q'); | |
/** | |
* Method to reduce observable to a promise. | |
* | |
* @param observable | |
*/ | |
function reduceToPromise(observable) { | |
return observable.reduce((acc, item) => [...acc, item], []) | |
.toPromise(Q.Promise); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment