Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

xstate hello world

node v10.15.3
version: 1.0.0
endpointsharetweet
const { Machine, interpret } = require("xstate") const toggleMachine = Machine({ initial: 'inactive', states: { inactive: { on: { TOGGLE: 'active' } }, active: { on: { TOGGLE: 'inactive' } } } }); const toggleService = interpret(toggleMachine) .onTransition(state => console.log(state.value)) .start(); // => 'inactive' toggleService.send('TOGGLE').value; // => 'active' toggleService.send('TOGGLE').value; // => 'inactive'
Loading…

no comments

    sign in to comment