Skip to content

Instantly share code, notes, and snippets.

@knownasilya
Created November 22, 2019 17:40
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 knownasilya/96cb98710f165296d3bbd34b2eed789d to your computer and use it in GitHub Desktop.
Save knownasilya/96cb98710f165296d3bbd34b2eed789d to your computer and use it in GitHub Desktop.
state machines ember
const machine = Machine({
  id: 'toggle',
  initial: 'inactive',
  states: {
    inactive: { on: { TOGGLE: 'active' } },
    active: { on: { TOGGLE: 'inactive' } }
  }
});
<XState @machine={{this.machine}}>
  {{when :inactive as |toggle|}}
    <Red @onClick={{toggle}}/>
  {{when :active as |toggle|}}
    <Green @onClick={{toggle}}/>
</XState>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment