Skip to content

Instantly share code, notes, and snippets.

@fgandellini
Last active January 27, 2020 08:53
Show Gist options
  • Save fgandellini/f5d5bfc01efe4fad0a75f9818db909aa to your computer and use it in GitHub Desktop.
Save fgandellini/f5d5bfc01efe4fad0a75f9818db909aa to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const portCallMachine = Machine({
id: 'port-call',
initial: 'settled',
states: {
hovered: {
on :{
MOUSE_LEAVE: 'settled.hist',
ITEM_SELECTED: 'selected',
MOUSE_CLICK: 'selected',
},
},
selected: {
on :{
MOUSE_CLICK_OUTSIDE: 'settled.hist',
},
},
settled: {
initial: 'default',
states: {
default: {
initial: 'idle',
states: {
idle: {
on: {
'': [
{ target: 'inactive', cond: 'notHitBycurrentRow' },
{ target: 'active', cond: 'hitBycurrentRow' },
],
},
},
inactive: {},
active: {},
},
on: {
MOUSE_MOVE: { target: 'default' },
LIVE_MOVES: { target: 'pending', cond: 'isFirstLiveMoves' },
},
},
pending: {
on: {
LIVE_MOVES: [
{ target: 'completed', cond: 'isLastLiveMoves' },
{ target: 'pending' },
],
},
},
completed: {},
hist: {
type: 'history',
history: 'deep',
},
},
on: {
MOUSE_ENTER: 'hovered',
},
},
},
}, {
guards: {
notHitBycurrentRow: () => true,
hitBycurrentRow: () => true,
isFirstLiveMoves: () => true,
isLastLiveMoves: () => true,
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment