Skip to content

Instantly share code, notes, and snippets.

@LevelbossMike
Created August 12, 2022 11:59
Show Gist options
  • Save LevelbossMike/357c8c2fea1ec8d132d49a4a772ab089 to your computer and use it in GitHub Desktop.
Save LevelbossMike/357c8c2fea1ec8d132d49a4a772ab089 to your computer and use it in GitHub Desktop.
Editior machine - for statechart visualizer
Machine({
id: 'editor',
type: 'parallel',
states: {
selection: {
initial: 'idle',
states: {
idle: {
on: {
SELECT: {
target: 'selected',
cond: 'selectionIncludesCells'
}
}
},
selected: {
on: {
SELECT: [
{
target: 'selected',
cond: 'selectionIncludesCells'
},
{
target: 'idle'
}
]
},
MOVE_SELECTION: {
actions: ['moveCells']
},
DELETE_SELECTION: {
actions: ['deleteCells']
},
}
}
},
// what interactions are possible atm
// this most likely depends on the thing we
// selected
interaction: {
initial: 'none',
states: {
none: {},
state: {
on: {
MOVE: {},
COLLAPSE: {}
}
},
states: {
on: {
MOVE: {},
}
},
event: {
on: {
DELETE: {},
CONNECT: {}
}
}
},
},
zoom: {
initial: 'active',
states: {
active: {
on: {
PAN_ZOOM: {},
RESET_ZOOM: {}
}
}
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment