Last active
April 21, 2020 01:06
-
-
Save njdancer/ff02299b8d9fab4468dd34d5e257e6f7 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 loadData = (callback, receive) => { | |
const intervalId = setInterval(() => { | |
callback({type:"DATA", data: "data"}) | |
console.log("called") | |
}, 2500) | |
return () => clearInterval(intervalId) | |
} | |
const appMachine = Machine({ | |
id: 'app', | |
initial: 'init', | |
context: { | |
}, | |
states: { | |
init: { | |
on: { | |
"DATA": { | |
actions: "assignData" | |
}, | |
"START": { | |
actions: assign({ | |
dataQuery: (context, event) => spawn(loadData) | |
}) | |
} | |
} | |
}, | |
idle: {}, | |
} | |
}, { | |
actions: { | |
assignData: assign({data: (_, event) => event.data}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment