Skip to content

Instantly share code, notes, and snippets.

@arielferdman
Last active October 26, 2020 12:26
Show Gist options
  • Save arielferdman/b7348ae88ad9ecb4ff146ca8096f5f44 to your computer and use it in GitHub Desktop.
Save arielferdman/b7348ae88ad9ecb4ff146ca8096f5f44 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const promiseMachine = Machine({
id: "promise",
initial: "pending",
states: {
pending: {
RESOLVE: "resolved",
REJECT: "rejected",
},
resolved: {
type: "final",
},
rejected: {
type: "final",
},
},
});
const promiseService = interpret(promiseMachine).onTransition(state =>
console.log(state.value)
);
promiseService.start();
promiseService.send('RESOLVE');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment