Created
May 24, 2020 23:58
-
-
Save mariorodriguespt/584241c1908bd53d9db59ebb405a7ee6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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