Created
June 23, 2020 18:14
-
-
Save jeremy-green/558f03ad9046b50de509e0f7b50460cc 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
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