Last active
November 9, 2020 15:40
-
-
Save Anveio/e8ec8c7fa72cdfc4ddf23eba580bbeda to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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 confidentialMachine = Machine({ | |
id: 'confidential', | |
initial: 'OFF', | |
context: { | |
dndEnabled: false, | |
retries: 0 | |
}, | |
on: { | |
ENABLE_DND: 'LOADING', | |
ACCESSORY_DISCONNECTED: 'DISABLED', | |
RESOLVE_ENABLE_DND: 'DISABLED', | |
}, | |
states: { | |
OFF: { | |
on: { | |
TURN_ON: 'LOADING' | |
}, | |
actions: assign({ | |
featureEnabled: () => false | |
}) | |
}, | |
ON: { | |
on: { | |
TURN_OFF: 'LOADING' | |
}, | |
actions: assign({ | |
featureEnabled: () => true | |
}) | |
}, | |
DISABLED: { | |
}, | |
LOADING: { | |
on: { | |
RESOLVE_ON: 'ON', | |
RESOLVE_OFF: 'OFF', | |
RESOLVE_ENABLE_DND: { | |
target: 'DISABLED', | |
actions: assign({ | |
dndEnabled: () => true | |
}) | |
}, | |
RESOLVE_DISABLE_DND: { | |
actions: assign({ | |
dndEnabled: () => false | |
}) | |
}, | |
ACCESSORY_COMMUNICATION_FAILURE: 'FAILURE' | |
} | |
}, | |
FAILURE: { | |
on: { | |
RETRY: { | |
target: 'LOADING', | |
actions: assign({ | |
retries: (context, event) => context.retries + 1 | |
}) | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment