-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(tap): added 'tap' function #17
base: master
Are you sure you want to change the base?
Conversation
README.md
Outdated
@@ -104,6 +104,31 @@ const rejectedTask = Task.resolve(new Error()); | |||
const rejectedPromise = toPromise(rejectedTask); | |||
``` | |||
|
|||
### `tap` | |||
|
|||
The `tap` _function_ can be found in other libreries. It just takes a `callback` _function_ and return a function that calls the `callback` and _returns_ the _argument_. It's useful when you need to perform some side effect. Suppose you need to log the _resolved value_ at certain point of a `Task` _method chaining_. Without the `tap` _function_ you would probably do something like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libraries...
Too many functions... try to modify with: It takes a callback and returns a function that invokes the callback with the parameter and pass it trough
README.md
Outdated
Task | ||
.resolve(0) | ||
// <Some code here...> | ||
.map(tap(console.log)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this works? when using console.log as a point free function weird things can happen
Gonza, cuando quieras reviví este PR :) |
Description
Adds the
tap
function, that calls a function and returns its parameter.Related issues
tap
#12