-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Lazy error evaluation of Result.OkIf and Result.FailIf #141
Comments
Looks good. Would be happy if you create a pr for this feature. I would be more happy if you also add some tests and extend the readme file with this feature. I will encrease the version number, write the changelog and generate the package. Thanks in advance |
Hi @altmann, thanks for a quick reply! The pull request, including overloads implementation, unit tests and a short section in the README is opened and ready for review. |
thank you for the great pr. I merged it already into the master branch. New package will be generated hopefully tomorrow. |
New package is out: https://www.nuget.org/packages/FluentResults |
As far as I am aware, the factory methods
OkIf
andFailIf
need theError
instances to be provided at the moment they are called.This may pop up in scenarios, where a reported
Error
instance requires access to the data which might not exist:The proposed feature would be to implement following method overloads:
Result.OkIf(bool condition, Func<string>)
Result.OkIf(bool condition, Func<Error>)
Result.FailIf(bool, Func<string>)
Result.FailIf(bool, Func<Error>)
which would enable lazy evaluation of the errors; modifying the previous snippet:
The workarounds to this are:
The text was updated successfully, but these errors were encountered: