-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Create a When system param wrapper for skipping systems that fail validation #18516
Description
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:
- Every system parameter errors by default when invalid.
- The
Option<T>wrapper turns an error into a successfulNoneparameter. - The
When<T>wrapper skips the system when it encounters an error. - 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)