-
Notifications
You must be signed in to change notification settings - Fork 310
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
Tap seems limited since you cannot halt execution on failure #181
Comments
You should be able to use The reason for the separation between |
I have not come up against many scenarios where I'd want to ignore the result completely, but I have come up against several scenarios where I would like to run an operation, check the result as normal, but return the original result rather than the new result. Unless I'm missing some context, using bind for this would amount to this code, correct?
This works, but the developers that I work with (and myself) usually end up writing extension methods like |
I do it this way: return GetCustomer()
.Bind(customer => UpdateCustomer(customer)
.Map(_ => customer))
.Bind(customer => DoWork(customer)
.Map(() => customer));
|
Thank you. We'll use |
@vkhorikov Do you think there is any case for adding a new method for this? |
Yeah, we should add this to the library. |
@vkhorikov Would you like me to create a PR? |
Please do. |
Consider whether it would be safer and more intuitive if we added See also #174 |
Addressed as part of PR #192 |
Tap is very useful in that you can use it to return the passed in result and do multiple operations on a single result object. For example.
However, sometimes you would like to return the result and still depend on whether the DoWork() method failed. If you could assume that
Func
s passed to DoWork all returned the same result type as the "parent" result, that would be useful.I find myself writing extensions methods like the following:
In this case, the flow would be identical, except that execution would stop when a tap
Func
returns a failed result.What is the reasoning behind having the result of a Tap operation be ignored in the railway flow?
The text was updated successfully, but these errors were encountered: