Created
October 28, 2020 15:32
-
-
Save jtiala/793757b9d89701f121ac90f83c0a8c64 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 bookingMachine = Machine({ | |
id: "booking", | |
initial: "idle", | |
context: { | |
fetched: { | |
purposes: undefined, | |
specifiers: undefined, | |
servicePoints: undefined, | |
appointmentTypes: undefined, | |
}, | |
selected: { | |
purpose: undefined, | |
specifiers: undefined, | |
appointmentType: undefined, | |
}, | |
}, | |
states: { | |
idle: { | |
on: { | |
NEXT: "fetchPurposes", | |
}, | |
}, | |
fetchPurposes: { | |
invoke: { | |
id: "fetchPurposes", | |
onDone: { | |
target: "selectPurpose", | |
actions: assign({ | |
fetched: (context, event) => ({ | |
purposes: event.data, | |
specifiers: event.data, | |
}), | |
}), | |
}, | |
onError: "failure", | |
}, | |
}, | |
selectPurpose: { | |
on: { | |
NEXT: "selectSpecifiers", | |
}, | |
}, | |
selectSpecifiers: { | |
on: { | |
NEXT: "fetchServicePoints", | |
}, | |
}, | |
fetchServicePoints: { | |
invoke: { | |
id: "fetchServicePoints", | |
onDone: { | |
target: "selectAppointmentType", | |
actions: assign({ | |
fetched: (context, event) => ({ | |
servicePoints: event.data, | |
appointmentTypes, | |
}), | |
}), | |
}, | |
onError: "failure", | |
}, | |
}, | |
selectAppointmentType: {}, | |
ready: { | |
type: "final", | |
}, | |
failure: { | |
type: "final", | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment