Skip to content

Conversation

germankuber
Copy link

This is the first approach for CombineSequential.

@germankuber
Copy link
Author

I would like to get a feedback. If you approve the idea, I will implement the method for more parameters

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))));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}


return Maybe<T>.None;
}
public static Result<K> Select<T, K>(this Result<T> maybe, Func<T, K> selector)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add Select overloads, those should be either Map or Bind.

return maybe.Map(selector);
}

[Obsolete("Use Bind instead of this method")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, no need to add new obsolete methods

Task<Result<string>> SecondFunction() => Task.FromResult(Result.Success("value"));

var result = await Result.CombineSequential(FirstFunction,
SecondFunction,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor (nit): the indentation is off.

@vkhorikov
Copy link
Owner

I've left a couple of comments. Otherwise, looks good, please proceed with the overloads.

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