Skip to content

Instantly share code, notes, and snippets.

@rschwabco
Last active February 5, 2021 23:20
Show Gist options
  • Save rschwabco/bfa189607b9e65ce0db4a350be902d9e to your computer and use it in GitHub Desktop.
Save rschwabco/bfa189607b9e65ce0db4a350be902d9e to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fleetScheduleApp = {
id: 'app',
initial: 'idle',
type: 'compound',
states: {
idle: {
id: 'app-idle',
on: {
eventClick: {
target: ".requirementSelected"
}
},
states: {
requirementSelected: {
on: {
'': '#detailsPanel.visible'
}
},
detailsPanel: {
id: 'detailsPanel',
states: {
hidden: {
type: 'final'
},
visible: {
type: 'final'
}
}
}
}
},
}
}
const fleetSchedule = Machine({
id: 'app-preloader',
initial: 'preload',
type: 'compound',
context: {
selectedRequirement: {},
selectedVessel: {},
},
states: {
ready: {
id: 'ready',
...fleetScheduleApp
},
preload: {
invoke: {
src: 'loadData',
onDone: {
target: 'ready'
},
onError: {
target: "failure",
},
}
},
failure: {
id: 'failure'
}
}
}, {
services: {
loadData: (context, event) => {
return new Promise((resolve, reject) => {
resolve()
})
}
},
actions: {
doAction: () => {}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment