const result: Result<number, string> = ok(1);
const value = tap(result, (data) => {
console.log(data);
});
// `1` gets logged by the callback;
result === value; // true
Tap into a result.
If the result is an Ok, the function will be called with the data the result contains.
Otherwise nothing will happen.
It will not modify the result, and just return the original result.
const result: Result<number, string> = ok(1);
const value = tap(result, (data) => {
console.log(data);
});
// `1` gets logged by the callback;
result === value; // true
Tap into a result.
If the result is an
Ok, the function will be called with the data the result contains.Otherwise nothing will happen.
It will not modify the result, and just return the original result.