Skip to content

Instantly share code, notes, and snippets.

@oshimayoan
Last active November 3, 2020 06:10
Show Gist options
  • Save oshimayoan/7cb55fd3832d17b85575b9d717c98348 to your computer and use it in GitHub Desktop.
Save oshimayoan/7cb55fd3832d17b85575b9d717c98348 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'prefetchWebView',
initial: 'idle',
context: {
},
states: {
idle: {
on: {
RERENDER: 'isFileExists',
}
},
isFileExists: {
on: {
YES: 'readFile',
NO: 'prefetch',
}
},
prefetch: {
on: {
RESOLVE: 'prefetchSuccess',
REJECT: 'prefetchFailure',
}
},
prefetchSuccess: {
on: {
SAVE: 'writeToFile'
}
},
prefetchFailure: {},
writeToFile: {
on: {
OPEN_WEBVIEW: 'readFile'
}
},
readFile: {
on: {
SUCCESS: 'readFileSuccess',
FAIL: 'readFileFailure'
}
},
readFileSuccess: {
on: {
RENDER_HTML: 'renderWebView'
}
},
readFileFailure: {
on: {
RENDER_URL: 'renderWebView'
}
},
renderWebView: {
type: 'final',
},
// idle: {
// on: {
// FETCH: 'loading'
// }
// },
// loading: {
// on: {
// RESOLVE: 'success',
// REJECT: 'failure'
// }
// },
// success: {
// type: 'final'
// },
// 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