Last active
January 4, 2022 07:27
-
-
Save peterlazar1993/6c83b77b4697b04e72631f1c85d7c94f 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const fetchMachine = Machine({ | |
id: "checkOTAUpdate", | |
initial: "CHECKING", | |
states: { | |
CHECKING: { | |
on: { | |
OTA_CHECK_SUCCESSFUL: [ | |
{target:'UPDATE_AVAILABLE', cond:'isUpdateAvailable' | |
}, | |
{target:'ON_LATEST_VERSION'} | |
], | |
OTA_CHECK_FAILED: 'CHECK_FAILED' | |
} | |
}, | |
CHECK_FAILED: {}, | |
UPDATE_AVAILABLE: { | |
initial: "IDLE", | |
states: { | |
IDLE:{ | |
on:{ | |
DOWNLOAD_OTA: "DOWNLOADING" | |
} | |
}, | |
DOWNLOADING: { | |
on: { | |
OTA_DOWNLOAD_SUCCESS: "DOWNLOADED", | |
OTA_DOWNLOAD_FAILED: "DOWNLOAD_FAILED", | |
}, | |
}, | |
DOWNLOADED: {type: 'final'}, | |
DOWNLOAD_FAILED: {}, | |
}, | |
}, | |
ON_LATEST_VERSION: {type: 'final'}, | |
}, | |
}, { | |
guards: { | |
isUpdateAvailable: (_, event) => { | |
return event.isUpdateAvailable | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment