Skip to content

[Feature Request] Hooks for Extensibility  #3

Description

@adamholdenyall

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions