Skip to content

toPromise

Callable


  • Returns a promise that resolves to the output of the actor when it is done.

    @example
    const machine = createMachine({
    // ...
    output: {
    count: 42
    }
    });

    const actor = createActor(machine);

    actor.start();

    const output = await toPromise(actor);

    console.log(output);
    // logs { count: 42 }

    Type parameters

    Parameters

    • actor: T

    Returns Promise<OutputFrom<T>>