Skip to content

Instantly share code, notes, and snippets.

@Kamisama666
Last active August 29, 2017 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kamisama666/54dc36ea40074f9a5a4b59f04a907724 to your computer and use it in GitHub Desktop.
Save Kamisama666/54dc36ea40074f9a5a4b59f04a907724 to your computer and use it in GitHub Desktop.
Method to reduce an RxJs Observable to a Promise.
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