OptionAsync<T>.Do(Action<T> Some, Action None)
#1455
Unanswered
IlyaVassyutovich
asked this question in
Q&A
Replies: 1 comment 3 replies
-
|
Quick solution: You can create two extensions methods -- one having |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Good day, fellow engineers.
The following question is about the V4-library
Today I needed to
Dosome actions on anOptionAsyncfor both its state variants. There is no out-of-the-box solution for this, or I couldn't find it. So I've tried to create my own extension method for this use case. This is what I've come up with:This extension works for me as intended, but there is a big caveat — look at the generic constraint. I can't use this extension with value types. And if I try to drop the constraint, factories of
OptionAsyncalways produceSomesince inside these factories, code is written likeif (value == null) ? none : some.Is there a better way that I'm not seeing?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions