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.

tap with promise chains

See original GitHub issue

I’d like to add tap variant to a promise chain (from composeP or pipeP) with the idea that the tap is dealing with a promise. Does a tapP function have any use? Or do we just do

var tapP = function (fn) {
     return function (promise) {
         return promise
             .then(function (x) {
                  fn(x);
                  return promise;
             });
     };
};

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
davidchamberscommented, Feb 27, 2017

@stevenyap, I recommend a Fantasy Land -compatible Future or Task type such as the one provided by Fluture.

0reactions
CrossEyecommented, Feb 27, 2017

I agree with @davidchambers. The main point is that Future/Task implementations follow known laws and can be used in a manner consistent with many other types. Promise implementations generally do not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tap into promise chains for debugging - Gleb Bahmutov
Let me show how combining promises can be simple if we separate building individual steps from linking them into a directed graph. Let...
Read more >
.tap | bluebird
In other words: throwing or returning a rejected/eventually-rejected promise will disrupt the chain as usual, but returning a value or a fulfilled/eventually- ...
Read more >
sindresorhus/p-tap: Tap into a promise chain ... - GitHub
tapHandler. Type: Function. Any return value is ignored. Exceptions thrown in tapHandler are relayed back to the original promise chain.
Read more >
Javascript Promise Chain Example Explained - YouTube
Javascript Promise Chain Execution Order Explained. In this tutorial, we explain how promises work in Javascript and how you can control the ...
Read more >
Promises chaining - The Modern JavaScript Tutorial
Promises provide a couple of recipes to do that. In this chapter we cover promise chaining. It looks like this: new Promise(function(resolve ...
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