question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Promise.then() is difficult to use with lambdas

See original GitHub issue

Currently 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:open
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sclassencommented, Oct 1, 2018

yes. DoneFilter returns D_OUT which is then wrapped in a new Promise<D_OUT, F, P>, where as DonePipe returns Promise<D_OUT, F_OUT, P_OUT> So if we would apply the DonePipe as a map() we would get Promise<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?

0reactions
aalmiraycommented, Oct 1, 2018

I get s/filter/map/ but isn’t pipe a variation of mapas well?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found