sebpiq / backbone.statemachine

Simple finite-state machine for Backbone. View states made easy. Synchronizing your application's parts with events made easy.
MIT License
177 stars 16 forks source link

Calling startStateMachine() twice make events happen twice #27

Closed Fab1en closed 11 years ago

Fab1en commented 11 years ago

If startStateMachine() is erroneously called twice, "all" events of the element are bound twice so every event triggered run the onMachineEvent callback twice.

It is very easy to make this mistake when you use the StatefulView version : you do not have to call startStateMachine() yourself in this case because it already has been called.

You should either make it safe to execute this code twice (by checking if it has already be initialized), or make it clear in the docs that startStateMachine() should not be called when using the StatefulView.

sebpiq commented 11 years ago

Fixed 50ca1b9b04cb366a092c07ec1513b5df0c371914