Skip to content

Instantly share code, notes, and snippets.

@jeremy-green
Created June 23, 2020 18:14
Show Gist options
  • Save jeremy-green/558f03ad9046b50de509e0f7b50460cc to your computer and use it in GitHub Desktop.
Save jeremy-green/558f03ad9046b50de509e0f7b50460cc to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
function timer(interval, msg) {
setInterval(() => console.log(msg), interval);
}
const initializerService = interpret(
new Machine({
initial: 'idle',
states: {
idle: {
on: {
INIT: {
target: 'ready',
},
},
},
ready: {
entry: [
() => console.log('%cmachine initialized...', 'font-weight: bold; font-size: 12px;'),
(_, { payload: { interval } }) => timer(interval, 'tock'),
],
},
},
}),
).start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment