Last active
April 7, 2020 22:25
-
-
Save sesteva/cac7459af3129a4e73b1fa1354307cd8 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
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