Skip to content

Instantly share code, notes, and snippets.

@YouMinTW
Created October 8, 2021 17:13
Show Gist options
  • Save YouMinTW/68fe859e9eef2de2667ff349d87e6dec to your computer and use it in GitHub Desktop.
Save YouMinTW/68fe859e9eef2de2667ff349d87e6dec to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const doorMachinceConfig = {
id: "door",
initial: "關著",
states: {
關著: {
on: { 開門: "開了" }
},
開了: {
on: {
關門: { target: "關著" }
}
}
}
};
// some FSM config
const someFSMConfig = {
id: "myId",
initial: "state1",
states: {
state1: {
on: {
event1: { target: "state2" }
}
},
state2: {
on: {
event2: { target: "state1" }
},
...doorMachinceConfig,
}
}
};
const fetchMachine = Machine(someFSMConfig);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment