Skip to content

Instantly share code, notes, and snippets.

@ilyaGotfryd
Last active June 10, 2021 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyaGotfryd/d63cc404df0be482cbd9844502e72327 to your computer and use it in GitHub Desktop.
Save ilyaGotfryd/d63cc404df0be482cbd9844502e72327 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 functionalSkillsMachine = Machine({
id: 'functionalSkills',
initial: 'idle',
context: {
retries: 0,
callibrated: false,
callibration: {}
},
states: {
idle: {
on: {
FETCH_GAMES: 'fetching_games'
}
},
fetching_games:{
on:{
SUCCESS: 'display_games'
}
},
display_games:{
on:{
SELECT_GAME:'load_game'
}
},
load_game:{
on:{
GAME_LOADED:'start_callibration'
}
},
start_callibration:{
on:{
'':[{target:'callibration', cond:'needCallibration'},
{target:'game_play'}]
}
},
callibration:{
id: 'callibration',
initial: 'pick_color',
states:{
pick_color:{
on:{
COLOR:'pick_hand',
SKIP: 'skip'
}
},
pick_hand:{
on:{
HAND: 'callibrate',
SKIP: 'skip'
}
},
callibrate:{
on: {
DONE: '#gamePlay',
SKIP: 'skip'
}
},
skip:{
on:{ '':[{target:'#gamePlay'}]}
}
}
},
game_play:{
id: "gamePlay",
initial: 'game_welcome_screen',
states:{
game_welcome_screen:{
id:'gameWelcomeScreen',
on:{
START_GAME:"game_start"
}
},
game_start:{
activities: ['keepAlive'],
on:{
PAUSE: 'game_pause'
}
},
game_pause:{
}
}
},
}
},{
activities:{
keepAlive: () => {
const intervalId = setInterval(keepAlive, 1000)
return () => clearInterval(intervalId)
}
},
guards: {
needCallibration: ctx => !ctx.callibrated
}
});
function keepAlive(){
console.log('keeping alive')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment