Returning Promises from Highland methods
See original GitHub issueMy workflow looks somewhat like this:
_(itemStream)
.map(function(item){ return doAsyncThing(item); })
.each(function(item){ console.log(item); });
… where doAsyncThing
returns a Bluebird promise. I had expected for Highland to await resolution of the promise and pass the final resolution value to the .each
call (much like Bluebird’s own .map
and .each
), but instead my .each
method is receiving the Promise objects themselves.
Is it possible to make Highland behave like I’m trying to accomplish, without having to manually .then
in the .each
handler, as that would defeat the point of doing things this way?
Issue Analytics
- State:
- Created 8 years ago
- Comments:30
Top Results From Across the Web
Highland.js
These methods return Stream objects, not Arrays, so you can chain together ... Promise - Accepts an ES6 / jQuery style promise and...
Read more >How to handle promise rejection when creating a highland ...
How can I only work on successful promises streams and ignore the failing ones using highland? How am I supposed to handle the...
Read more >Promise - JavaScript - MDN Web Docs
Returns a new Promise object that is resolved with the given value. If the value is a thenable (i.e. has a then method),...
Read more >Coming from Other Libraries - Bluebird JS
Bluebird treats jQuery deferreds and promises interchangeably. Wherever you can take a promise or return a promise, you can take or return a...
Read more >Dallas CAD – Official Site
We anticipate the return of our full functioning website sometime in early 2023. The authorities are aware of our ransomware case and we...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can use
flatMap
and wrap the promise in a stream:Ha. Your answer is actually better because it explains why it works.