contains(name, MachineDef, [states], [conditions]) to define submachines
on('@attach') event, triggered on machine creation
on('@detach') event, triggered on machine destruction
.children[name] to access child machines
contains(name) to check containtent existance.
signalFrom(nameMachine, event, [states]) - to respont to signals.
const clockMachine = faste()
.on('@init',({setState, attrs, trigger}) => setState({
interval: setInterval(() => emit('next'), attrs.duration)
}))
.on('@destroy', ({state}) => clearInterval(state.interval));
const light = faste()
// simple machine
.contains('clock', clockMachine)
// with dynamic constructor
.contains('clock', ({attrs}) => ({faste: clockMachine, attrs: { duration: attrs.duration || 10}})))
.signalFrom('clock', 'tick', ({emit}) => trigger('switch'))
.on('tick',['on'], ({transitTo}) => transitTo('off'))
.on('tick',['off'], ({transitTo}) => transitTo('on'))
contains(name, MachineDef, [states], [conditions])to define submachineson('@attach')event, triggered on machine creationon('@detach')event, triggered on machine destruction.children[name]to access child machinescontains(name)to check containtent existance.signalFrom(nameMachine, event, [states])- to respont to signals.