javascript-state-machine
javascript-state-machine copied to clipboard
providing in config listener returning promise makes transition unusable
For
const config = {
init: 'NEW',
transitions: [{
name: 'init', from: 'NEW', to: 'READY'
}],
methods: {
onBeforeTransition: function () {
// here any code always returning promise - with more sense than below ;)
return Promise.resolve(true);
}
}
}
const sm = new StateMachine(config);
console.log(sm.state); // here state is 'none' - no way to wait until sm is ready to be used.
an idea would be to provide some method i.e. pendingTransition()
returning promise to be able to act only when state machine is ready to be used.