Open adamholdenyall opened 10 years ago
Definitely, I think this is a good idea.
How about having a method called onTransition(from:T, to:T)
available for overriding?
Sounds good. That should do the trick :)
Checked in a new dist with v1.0.1, I'll be publishing the packages a little later :) I'll close this issue when I publish the new version to bower, nuget, and npm
I have been working on trying to make a child of the FiniteStateMachine class, and I've run into an issue.
I'm working on giving each state a list of Behavior objects. The behavior objects have a functions that can be overloaded for entering, updating and exiting at that state.
Problem is, the only way I can detect an enter or an exit is by keeping a reference to the previous state, and comparing it to the current state. But this can cause problems.
I think for the sake of extensibility, it would be awesome to have a dummy function that can be overridden to perform some code anytime the state changes.
Something like onAnyEnter(from, to) {} that would run after onEnter is validated inside_transitionTo. You could either set the function at runtime or overriding in a subclass. Because so much is private (for good reason), it's hard to extend the class.
Think this is something you would be willing to have in the library?