Skip to content

Instantly share code, notes, and snippets.

@7hny
Last active November 18, 2020 21:03
Show Gist options
  • Save 7hny/128a37a76852e19964abb995b0f27bed to your computer and use it in GitHub Desktop.
Save 7hny/128a37a76852e19964abb995b0f27bed 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 showListStates = {
initial: 'walk',
states: {
noSessionData: {
},
noTicketData: {},
noData: {}
}
};
const toggleMachine = Machine({
id: 'toggle',
context: {
/* some data */
},
initial: 'idle',
states: {
idle: {
on: {
FETCH_DATA: {
target: "fetchingData"
}
}
},
fetchingData: {
on: {
TOKEN_NOT_FOUND: {
target: 'showList'
},
TOKEN_FOUND: {
target: 'tokenValidation'
}
}
},
tokenValidation: {
on: {
INVALID_TICKET: {
target: 'showList'
},
INVALID_SESSION: {
target: 'showList'
},
INVALID_SHOW: {
target: 'showList'
},
VALID: {
target: 'showCountdown'
}
}
},
showList: {
...showListStates
},
showCountdown: {},
incorrectShowId:{},
incorrectTicketId:{},
incorrectSessionId:{},
invalidToken:{},
invalidTicket:{},
missingToken:{},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment