Skip to content

Instantly share code, notes, and snippets.

@2WheelCoder
Last active July 22, 2021 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2WheelCoder/2f45a26810e2c044d7f9f289efdf9210 to your computer and use it in GitHub Desktop.
Save 2WheelCoder/2f45a26810e2c044d7f9f289efdf9210 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const explorerMachine = Machine({
id: 'explorer',
initial: 'idle',
context: {
activeLayers: [],
filters: [],
geos: [],
networkLinks: [],
transitStops: [],
transitRoutes: [],
isFilterPanelOpen: [],
},
states: {
idle: {
on: {
APPLY_LAYER_FILTER: 'loadingData',
EDIT_GEOS: 'selectingGeos',
EDIT_NETWORK_LINKS: 'selectingNetworkLinks',
EDIT_TRANSIT_STOPS: 'selectingTransitStops',
EDIT_TRANSIT_ROUTES: 'selectingTransitRoutes',
}
},
loadingData: {
on: {
RESOLVE: 'idle',
REJECT: 'failure'
}
},
loadingMap: {
on: {
RESOLVE: 'idle',
REJECT: 'failure'
}
},
selectingGeos: {
on: {
APPLY_LAYER_FILTER: [{
target: 'loadingData',
cond: 'hasGeosSelected'
}, {
target: 'invalidSelection'
}]
}
},
selectingNetworkLinks: {},
selectingTransitStops: {},
selectingTransitRoutes: {},
invalidSelection: {},
failure: {}
// failure: {
// on: {
// RETRY: {
// target: 'loading',
// actions: assign({
// retries: (context, event) => context.retries + 1
// })
// }
// }
// }
}
}, {
// actions: {
// toggleLayerVisibility: (context)
// },
guards: {
hasGeosSelected: (context) => context.geos.length
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment