Skip to content

Feature: Zip method for fetching an Outcome, without losing reference to the original Outcome #3

@sameera

Description

@sameera

Scenario:
You need to call two async functions and use results of both the functions in a calculation. Without the ForkJoin, you'll be forced to store the first result on a variable while you call the 2nd function.

A a = null;
await getA()
  .Then(result => {
    a = result;
    return getB();
  })
  .Then(b => Process(a, b));

With forkJoin:

await GetA()
  .ForkJoin(() => GetB()) // optionally .ForkJoin(a => GetB(a)) if that was required.
  .Then((a, b) => Process(a, b));

Signature:

public static Task<Outcome<ValueTuple<A, B>>> ForkJoin<A, B>(
  this Task<Outcome<A>> source, 
  Func<Task<Outcome<B>>> handler
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions