Last active
January 27, 2021 22:04
-
-
Save rschwabco/b15b80b697b128af4dd39f49c478aad0 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 vesselIsNotASpot = () => {} | |
const requirementUnlocked = () => {} | |
const requirementCanBeAssignedToVessel = () => {} | |
const fetchMachine = Machine({ | |
id: 'fleetSchedule', | |
initial: 'idle', | |
states: { | |
idle: { | |
id: 'idle', | |
type: 'initial', | |
on: { | |
TOUCH_VESSEL: 'interactingWithVessel', | |
TOUCH_REQUIREMENT: 'interactingWithRequirement', | |
ZOOM_INCREASE: { | |
actions: ['zoomIn'] | |
}, | |
ZOOM_DECREASE: { | |
actions: ['zoomOut'] | |
}, | |
UPDATE_VESSEL_FILTER: { | |
actions: ['updateVesselFilter'] | |
} | |
} | |
}, | |
interactingWithVessel: { | |
on: { | |
VESSEL_CLICKED:{ | |
target: 'detailsPanelOpen.vesselShown', | |
cond: vesselIsNotASpot | |
} | |
}, | |
states: { | |
vesselShownInDetails: { | |
type:'final' | |
} | |
} | |
}, | |
detailsPanelOpen: { | |
id: 'detailsPanelOpen', | |
entry: ['openDetailsPanel'], | |
states: { | |
requirementShown: { | |
type: 'final' | |
}, | |
vesselShown: { | |
type: 'final' | |
}, | |
requirementUnassignmentShown: { | |
type: 'final' | |
} | |
}, | |
on: { | |
CLOSE: { | |
entry: ['closeDetailsPanel'], | |
target: '#idle' | |
} | |
} | |
}, | |
interactingWithRequirement: { | |
on: { | |
CLICK: { | |
target: 'detailsPanelOpen.requirementShown', | |
}, | |
RIGHT_CLICK: { | |
target: 'detailsPanelOpen.requirementUnassignmentShown', | |
}, | |
DRAG: { | |
target: '.requirementDragged', | |
cond: requirementUnlocked | |
}, | |
DROP: {target:'.requirementDropped', cond: requirementCanBeAssignedToVessel | |
} | |
}, | |
states: { | |
requirementUnassignmentDialog: { | |
type: 'final' | |
}, | |
requirementDragged: { | |
entry: ['updateRequirementLocation'] | |
}, | |
requirementDropped: { | |
exit: ['assignRequirementToVessel'] | |
} | |
} | |
}, | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment