Skip to content

Create a When system param wrapper for skipping systems that fail validation #18516

Closed
@alice-i-cecile

Description

@alice-i-cecile

I really like the optional system param thing, I was wondering about that myself.

I'm less sold on having a single skipping wrapper; however if we did decide to go with it my vote would be to call it When<T> (eg. When<Res<MyResource>> or When<Single<Window>> or When<Populated<MyComponent>>) to indicate that this system runs when the parameter is valid.

Just having a few separate wrappers with this functionality built in seems fine. Having a dedicated When<T> wrapper does increase flexibility somewhat... There are situations where users may want their app to panic if they don't have exactly one entity with a single value, I think I've had situations where I'd have liked to enforce that invariant before.


Just so we are all on the same page, your proposed semantics would basically be:

  1. Every system parameter errors by default when invalid.
  2. The Option<T> wrapper turns an error into a successful None parameter.
  3. The When<T> wrapper skips the system when it encounters an error.
  4. The fallback error handler lets users further customize how unwrapped errors are handled.

I don't hate that. One slightly awkward result is the behavior of Option<When<T>> and When<Option<T>>. Should the former skip?

Originally posted by @NthTensor in #18504 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedX-ControversialThere is active debate or serious implications around merging this PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions