Last active
November 1, 2019 19:27
-
-
Save tbergman/d476a110783405e93e0f5165ac5fc3f8 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
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