Open
Conversation
…lExtensions into features/combine-sequential
Author
|
I would like to get a feedback. If you approve the idea, I will implement the method for more parameters |
vkhorikov
reviewed
Apr 19, 2021
| Func<Task<Result<TDataB>>> b, | ||
| Func<(TDataA DataA, TDataB DataB), TReturnData> combineFunction) | ||
| => await (await a()) | ||
| .Bind(async resultA => (await b()).Map(resultB => combineFunction((resultA, resultB)))); |
Owner
There was a problem hiding this comment.
Such one-lines are hard to read. Please decompose into several lines, such as:
{
var resultA = await a();
var resultB = await b();
// Bind, Map, etc
}
vkhorikov
reviewed
Apr 19, 2021
|
|
||
| return Maybe<T>.None; | ||
| } | ||
| public static Result<K> Select<T, K>(this Result<T> maybe, Func<T, K> selector) |
Owner
There was a problem hiding this comment.
Please don't add Select overloads, those should be either Map or Bind.
vkhorikov
reviewed
Apr 19, 2021
| return maybe.Map(selector); | ||
| } | ||
|
|
||
| [Obsolete("Use Bind instead of this method")] |
Owner
There was a problem hiding this comment.
Same here, no need to add new obsolete methods
vkhorikov
reviewed
Apr 19, 2021
| Task<Result<string>> SecondFunction() => Task.FromResult(Result.Success("value")); | ||
|
|
||
| var result = await Result.CombineSequential(FirstFunction, | ||
| SecondFunction, |
Owner
There was a problem hiding this comment.
Minor (nit): the indentation is off.
Owner
|
I've left a couple of comments. Otherwise, looks good, please proceed with the overloads. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the first approach for CombineSequential.