Skip to main content
Module

x/xstate/src/toPromise.ts>toPromise

Actor-based state management & orchestration for complex app logic.
Go to Latest
function toPromise
import { toPromise } from "https://deno.land/x/xstate@xstate%405.9.1/src/toPromise.ts";

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

Examples

Example 1

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

const actor = createActor(machine);

actor.start();

const output = await toPromise(actor);

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