Skip to content

Instantly share code, notes, and snippets.

@sesteva
Last active April 7, 2020 22:25
Show Gist options
  • Save sesteva/cac7459af3129a4e73b1fa1354307cd8 to your computer and use it in GitHub Desktop.
Save sesteva/cac7459af3129a4e73b1fa1354307cd8 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const queueMachine = Machine({
id: 'queue',
initial: '',
context: {
queue: []
}
})
const calendarMachine = Machine({
id: 'calendar',
initial: 'initializing',
context: {
initialValues: [],
activities: [],
morning: [],
afternoon: [],
selected: {}
},
states: {
initializing: {
entry: assign({
morning: (ctx, e) => spawn(queueMachine.withContext(ctx.initialValues))
}),
on: {
SELECT: 'selecting',
ADD: 'idle'
}
},
idle: {
on: {
'': 'selecting'
}
},
selecting: {
on: {
'': 'idle'
}
}
}
});
const initialSchedule = [...Array(30)].map( (_,i) => ({'id': i, 'name': 'EMPTY'}) );
calendarMachine.withContext((initialSchedule))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment