bluebird-api
bluebird-api copied to clipboard
Promise.map(), Promise.filter(), etc. return native Promises instead of Bluebird
#goodnessSquad
k
What you did won't do. As long as an async
function returns a native Promise, you need to wrap the whole thing with return Bluebird.resolve((async () => {})());
Hey there :)
This project looks very promising - nice work! I have a couple of questions, if you may:
- When this issue is resolved,
async
functions will return thebluebird-api
version of native promises? - If so, will it be possible to use the bluebird
cancel()
API in conjunction withasync
functions?
Thanks!
No to both. Sadly, as it currently stands, async
functions always return native promises, that's why there's a return Bluebird.resolve()
around every function implementation.
I see.
So there is actually no practical way to use cancellations with native async
functions in node?
It would have been really nice if there was a way to monkeypatch native promises to support these kinds of things that will probably never make it to ECMAScript...
There was a proposal that allowed this - it was rejected (compositional functions)
There was another proposal that allowed this (cancellable promise) which was also rejected.
Sorry - the good people of th TC don't like these proposals very much - and the sad truth is that there is politics involved.
On the other hand, you can manually use tokens
I don't care very much for tokens - I started using them when I thought the proposal will be accepted but once it was dropped I decided to go back to bluebird-style cancel which is a much better approach in my eyes.
The question is: is it possible that node will ever provide its own hooks for extending promises, regardless of the ECMAScript standard? It seems like a pretty simple then
interceptor would enable one to implement custom cancellations.
@itsysabato - we can discuss this at Node - if you have a concrete proposal.
However, I have to say chances are pretty slim.
@benjamingr OK then. Thanks a lot anyway!
@itaysabato sure, and sorry for losing :)