jakesgordon / javascript-state-machine

A javascript finite state machine library
MIT License
8.69k stars 964 forks source link

Add transitions after calling constructor #142

Open inakie opened 6 years ago

inakie commented 6 years ago

Is there a way to add new transitions/states after the first call to the constructor?

I have tried doing this

fsm._fsm.config.mapTransition({
  name: "startPause",
  from: "game",
  to: "pause"
});

but I get a fsm.startPause is not a function error.

Check out this codepen for my test Thanks!

rickbsgu commented 6 years ago

Not sure why you would want to do this -- the whole idea of a 'finite state' machine is that there are a finite number of possible states. Adding states/transitions dynamically kinda breaks that paradigm...