javascript-state-machine icon indicating copy to clipboard operation
javascript-state-machine copied to clipboard

providing in config listener returning promise makes transition unusable

Open ciekawy opened this issue 4 years ago • 1 comments

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.

ciekawy avatar Aug 06 '19 09:08 ciekawy