Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Hooks for Extensibility #3

Open
adamholdenyall opened this issue May 10, 2014 · 3 comments
Open

[Feature Request] Hooks for Extensibility #3

adamholdenyall opened this issue May 10, 2014 · 3 comments

Comments

@adamholdenyall
Copy link

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?

@eonarheim
Copy link
Owner

Definitely, I think this is a good idea.

How about having a method called onTransition(from:T, to:T) available for overriding?

eonarheim added a commit that referenced this issue May 11, 2014
@adamholdenyall
Copy link
Author

Sounds good. That should do the trick :)

eonarheim added a commit that referenced this issue May 12, 2014
@eonarheim
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants