Skip to content

Ergonomic way to get exited state in OnExit system #18066

@tmstorey

Description

@tmstorey

What problem does this solve or what need does it fill?

If you have to run the same logic when exiting multiple states, you might want to reuse the same system in multiple OnExit schedules. Unfortunately, Res<State<_>> returns the state that is being entered, not the one that was just exited, so the only way to get the previous state is to read the StateTransitionEvent.

What solution would you like?

Either have Res<State<_>> return the state being exited, or add something like PreviousState.

What alternative(s) have you considered?

As I said above, I'm currently using the StateTransitionEvent, but it's a bit clumsy.

Additional context

None that I'm aware of.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-StatesApp-level states machinesC-FeatureA new feature, making something new possibleD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedX-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions