Skip to content

Instantly share code, notes, and snippets.

@mbreton
Created Jul 2, 2020
Embed
What would you like to do?
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: 'consent',
initial: 'created',
context: {
},
states: {
created: {
on: {
start: {
target: 'started',
actions: ['sendPushNotif']
}
}
},
started: {
on: {
grant: 'OperationCommiting',
refuse: 'OperationRefusing',
cancel: 'OperationCanceling'
}
},
OperationCommiting: {
on: {
callBackIsOk : {
target:"granted",
actions: ['sendPushNotif']
},
callBackIsKo : {
target:"failed",
actions: ['sendPushNotif']
}
}
},
OperationRefusing: {
on: {
callBackIsOk : {
target:"refused",
actions: ['sendPushNotif']
},
callBackIsKo : {
target:"failed",
actions: ['sendPushNotif']
}
}
},
OperationCanceling: {
on: {
callBackIsOk : {
target:"canceled",
actions: ['sendPushNotif']
},
callBackIsKo : {
target:"failed",
actions: ['sendPushNotif']
}
}
},
granted: {
type: 'final'
},
refused: {
type: 'final'
},
canceled: {
type: 'final'
},
failed: {
type: 'final'
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment