Skip to content

Instantly share code, notes, and snippets.

@tbergman
Last active November 1, 2019 19:27
Show Gist options
  • Save tbergman/d476a110783405e93e0f5165ac5fc3f8 to your computer and use it in GitHub Desktop.
Save tbergman/d476a110783405e93e0f5165ac5fc3f8 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const SPLASHSCREEN_SHOW_TIME = 1000;
const AppStates = {
Splashscreen: "Splashscreen",
Menu: "Menu",
Playing: "Playing",
Gameover: "Gameover"
}
const AppEventType = {
StartNewGame: "StartNewGame",
ExitToMenu: "ExitToMenu"
}
const INITIAL_APP_CONTEXT = {};
const GameActionType = {
AwardPoints: "AwardPoints"
}
const appActions = {};
const appConfig = {
id: "app",
initial: AppStates.Splashscreen,
context: INITIAL_APP_CONTEXT,
states: {
[AppStates.Splashscreen]: {
after: {
[SPLASHSCREEN_SHOW_TIME]: AppStates.Menu
}
},
[AppStates.Menu]: {
on: {
[AppEventType.StartNewGame]: {
target: AppStates.Playing
}
}
},
[AppStates.Playing]: {
on: {
[AppEventType.ExitToMenu]: {
target: AppStates.Menu
}
}
},
[AppStates.Gameover]: {}
}
};
const appGuards = {};
const appMachine = Machine(
appConfig,
{
actions: appActions,
guards: appGuards
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment