Promise.then() is difficult to use with lambdas
See original GitHub issueCurrently Promise.then
takes 3 different types of inputs: DoneCallback
, DoneFilter
, and DonePipe
. This forces explicit casts when using lambda expressions. It would be better if this method were to be split in 3 variants, such as
then(DoneCallback cbk)
thenFilter(DoneFilter fltr)
thenPipe(DonePipe pipe)
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Lambda function returning a promise from a function not working
My first function gets a row form DB based on ID, if row is not present I want to return error response and...
Read more >Polish your asynchronous code with Promises in Node.js - Blog
Handling asynchronous JavaScript gracefully can be fairly hard to get right. Using the Promise function is a good way to avoid getting stuck ......
Read more >Promise.all won't work in AWS lambda code - Reddit
I have tested this code locally several times, but after deployment on AWS, it stopped working. I have just added simple code to...
Read more >Common Mistakes While Writing Node JS Function for AWS ...
Common Mistakes While Writing Node JS Function for AWS Lambda · 2. Promise not executing in Lambda · 3. Still using callbacks ·...
Read more >Stretching Async/Await With Lambdas - DZone Java
To interact with a promise we may use its then() method, which registers callbacks to receive its eventual result. Considering p a promise...
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
yes. DoneFilter returns
D_OUT
which is then wrapped in a newPromise<D_OUT, F, P>
, where as DonePipe returnsPromise<D_OUT, F_OUT, P_OUT>
So if we would apply the DonePipe as a map() we would getPromise<Promise<D_OUT, F_OUT, P_OUT>, F, P>
Because this is just complicated and does not add any value the pipe operation unwraps the inner promise. The same does the flatMap() on streams. it unwraps a stream in a stream -> it flattens the generic…Does this explanation help?
I get
s/filter/map/
but isn’tpipe
a variation ofmap
as well?