You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
110
+
111
+
```typescript
112
+
Task
113
+
.resolve(0)
114
+
// <Some code here...>
115
+
.map(resolvedValue=> {
116
+
console.log(resolvedValue);
117
+
returnresolvedValue;
118
+
})
119
+
// <And more code here...>
120
+
```
121
+
122
+
You can't use an _inline function_ nor a _point-free_ style because you don't want the _log_ to change the `Task`'s _resolved value_, so you need to _return_ it. It's way more fancier and handy to just use the `tap`_function_:
0 commit comments