Skip to content

Conversation

marcinjahn
Copy link
Contributor

I find the existing Execute/ExecuteNoValue extensions a bit inconvenient, due to:

  1. Naming that could just reuse the established Tap nomenclature (used in Result already)
  2. void return type prohibiting fluent method chaining.

With Execute the flow looks as follows:

var maybe = GetMaybe();

maybe.ExecuteNoValue(() => logger.LogWarning("There was no value"));

return maybe.Or(someDefaultValue);

With the new Tap, it could be:

return GetMaybe()
   .TapNoValue(() => logger.LogWarning("There was no value"))
   .Or(someDefaultValue);

I also added Obsolete attribute to Execute since I think it's not really needed when Tap is there. Please do let me know if that's alright.

The new code is really just a copy of existing Execute/ExecuteNoValue code with added return functionality. Tests are also mostly copied.

@vkhorikov
Copy link
Owner

This looks good. Could you re-push the PR? looks like there was an issue during build

Maybe.Tap and Maybe.TapNoValue are able to take over the deprecated
methods with added functionality.
@marcinjahn
Copy link
Contributor Author

@vkhorikov Is everything alright now? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants