Last active
October 26, 2020 12:26
-
-
Save arielferdman/b7348ae88ad9ecb4ff146ca8096f5f44 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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