Last active
January 24, 2020 15:34
-
-
Save fgandellini/520709639208ac6c19782ef4f01bd479 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const portCallMachine = Machine({ | |
id: 'port-call', | |
type: 'parallel', | |
states: { | |
mouse: { | |
initial: 'idle', | |
states: { | |
idle: { | |
on :{ | |
MOUSE_MOVE: { | |
target: 'active', | |
cond: 'hitBycurrentRow', | |
}, | |
}, | |
}, | |
active: { | |
on :{ | |
MOUSE_MOVE: { | |
target: 'idle', | |
cond: 'notHitBycurrentRow', | |
}, | |
MOUSE_ENTER: 'hovered', | |
}, | |
}, | |
hovered: { | |
on :{ | |
MOUSE_LEAVE: [ | |
{ target: 'idle', cond: 'notHitBycurrentRow' }, | |
{ target: 'active', cond: 'hitBycurrentRow' }, | |
], | |
MOUSE_CLICK: 'selected', | |
}, | |
}, | |
selected: { | |
on :{ | |
MOUSE_CLICK_OUTSIDE: [ | |
{ target: 'idle', cond: 'notHitBycurrentRow' }, | |
{ target: 'active', cond: 'hitBycurrentRow' }, | |
], | |
}, | |
}, | |
}, | |
}, | |
operations: { | |
initial: 'none', | |
states: { | |
none: { | |
on: { | |
LIVE_MOVES: { | |
target: 'pending', | |
cond: 'isFirstLiveMoves', | |
}, | |
}, | |
}, | |
pending: { | |
on: { | |
LIVE_MOVES: { | |
target: 'completed', | |
cond: 'isLastLiveMoves', | |
}, | |
}, | |
}, | |
completed: {}, | |
}, | |
}, | |
}, | |
}, { | |
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