Skip to content

Instantly share code, notes, and snippets.

@edokeh
Created December 19, 2019 07:38
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 edokeh/126c64889d0b97d0bb50279fa7d93b07 to your computer and use it in GitHub Desktop.
Save edokeh/126c64889d0b97d0bb50279fa7d93b07 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)
let lionMachine = Machine(
{
id: 'lion',
initial: 'idle',
context: {
displayIndex: 0
},
states: {
idle: {
on: {
CLICK: 'jiaohu',
UP_CLICK: 'preUpgrade'
},
entry: 'play'
},
jiaohu: {
type: 'parallel',
states: {
animation: {
initial: 'idle',
states: {
idle: {
on: {
LOOP_END_hudong: [
{
target: '#lion.idle',
in: '#lion.jiaohu.rpc.end'
},
{ target: 'idle' }
]
},
entry: 'play'
}
}
},
rpc: {
initial: 'init',
states: {
init: {
invoke: {
src: 'poke',
onDone: 'end',
onError: 'end'
}
},
end: {
type: 'final'
}
}
}
}
},
preUpgrade: {
invoke: {
src: 'fetchUpgrade',
onDone: {
target: 'upgrade',
actions: assign((context, event) => ({ displayIndex: event.data.displayIndex }))
},
onError: 'idle'
}
},
upgrade: {
on: {
END: 'idle'
},
entry: 'play'
}
}
},
{}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment