jakesgordon / javascript-state-machine

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

[Question] 'init' interferes with 'onTransition' and 'onEnterState' #150

Closed Red-Maximus closed 6 years ago

Red-Maximus commented 6 years ago

Forgive me if I missed something, but I haven't found anything in the documentation to clear up my issue.

I'm using this library for a task workflow and I want the $scope.task to get updated with state info on every transition. The problem being, the onTransition and onEnterState methods fire after the init which means I have to write some special logic to handle the errors it throws.

Is there an easy way to exclude the init from the onTransition or onEnterState methods? Or is there another method for this?

I cannot reasonably/cleanly write this method for every state I have since there are many.