-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[v5] Higher-level guards #1456
[v5] Higher-level guards #1456
Conversation
🦋 Changeset detectedLatest commit: 8fcbddd The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 0fe1e18:
|
Really like this idea. Captures more interesting visualizable intent, too! Given the variadic signature, wondering if |
After further thought, now I've convinced myself you had it right with 🤷 |
guard: { | ||
type: 'testGuard', | ||
name: 'any', | ||
children: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super convinced that having a custom predicate that is responsible for resolving its children is a good idea - if u need something like this you can already use params
, shouldn't children
just be reserved for combinators like not
, and
and or
?
In other words - could u prepare a real-life example of such a thing used in practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if u need something like this you can already use
params
Not exactly, since params
are just params - they're not resolved. children
are resolved.
The usefulness of this is so that custom guards that might need to reference other guards can be made in userland (such as xor(...)
, etc.).
@davidkpiano |
This PR aims to simplify the implementation details and TS types for guards, as well as adds the following higher-level guards:
and([someGuard, anotherGuard, ...])
or([someGuard, anotherGuard, ...])
not(someGuard)
These higher-level guards can be combined at any depth:
And parameterized guards can use these higher-level guards:
It also will rename
cond
toguard
in transitions, as this has been a common source of confusion.TODO:
and([...])
+ testsor([...])
+ testsnot(...)
+ testsAdd other boolean guards (if applicable)Enable "guard definitions" in(not in this PR)guards
instead of just predicatescond
toguards