Skip to content

Instantly share code, notes, and snippets.

@mariorodriguespt
Created May 24, 2020 23:58
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 mariorodriguespt/584241c1908bd53d9db59ebb405a7ee6 to your computer and use it in GitHub Desktop.
Save mariorodriguespt/584241c1908bd53d9db59ebb405a7ee6 to your computer and use it in GitHub Desktop.
const toggleMachine = createMachine({
id: 'toggle',
initial: 'inactive',
states: {
inactive: { on: { TOGGLE: 'active' } },
active: { on: { TOGGLE: 'inactive' } }
}
});
class SimpleToggle {
constructor() {
this.isActive = 'inactive';
}
toggle(){
this.isActive = this.isActive === 'active' ? 'inactive' : 'active';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment