vkhorikov / CSharpFunctionalExtensions

Functional extensions for C#

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal for a TapIf overload

fliebrecht opened this issue · comments

I think the overload of TapIf with the signature (this Task resultTask, Func predicate, Action action) is missing (hopefully my implementation is correct):

    public static async Task<Result> TapIf(this Task<Result> resultTask, Func<bool> predicate, Action action)
    {
        Result result = await resultTask.DefaultAwait();

        if (result.IsSuccess && predicate())
            return result.Tap(action);
        else
            return result;
    }

Looks good to me, feel free to submit a PR.