Skip to content

Instantly share code, notes, and snippets.

@mikaelkaron
Created September 27, 2019 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikaelkaron/f747f04d0bd68338c437ac34c559e0e3 to your computer and use it in GitHub Desktop.
Save mikaelkaron/f747f04d0bd68338c437ac34c559e0e3 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// contrived example - reads from the `context` and sends
// the dynamically created event
const sendNameObjectFn = send((context, event) => ({
type: 'NAME',
name: context.user.name
}));
const sendNameObject = send({ type: 'NAME' });
const sendNameString = send('NAME');
const machine = Machine({
initial: 'initial',
states: {
initial: {}
},
// ...
on: {
TOGGLE: {
actions: sendNameObject
}
}
//...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment