feat(jarl-atoms)!: 420 — unionRouteAtom, and notAtom taking one route plus options - #110
Open
randomdevpete wants to merge 2 commits into
Open
feat(jarl-atoms)!: 420 — unionRouteAtom, and notAtom taking one route plus options#110randomdevpete wants to merge 2 commits into
randomdevpete wants to merge 2 commits into
Conversation
A route that matches wherever any of its members does, and exactly wherever any
member matches exactly. `values`, `rest` and `reverse` come from the member that
actually matched — the exact one where there is one, so an ancestor that matches
every location beneath it never shadows the leaf that rendered, and only the
non-exact fallback depends on the order given.
Because it is a `RouteAtom` and not a boolean, it composes: as another route's
`parent`, in `<Route on={...}>`, or as a whole route list handed to `notAtom`.
Its `values` are the union of its members', via a new `RouteValues` type, so a
chain of increasingly specific routes reads as one route bound to a union of
their params.
A union has no URL shape of its own, so `reverse` and writes go to whichever
member matches and to the first listed when none does.
Ticket: 420
The variadic first param was the only thing standing between `notAtom` and a
second argument, and with `unionRouteAtom` the whole route list is expressible
as one route, so the spread buys nothing. `notAtom(unionRouteAtom([...]))`
replaces `notAtom(...routes)`, and the exactness the old signature hard-coded
becomes the option the freed-up slot allows: `{ exact: false }` counts an
ancestor match too. It still defaults to true, because an ancestor is
`match: true` for every location beneath it and only the leaf's exactness says
whether anything was found.
BREAKING CHANGE: `notAtom` takes a single route atom rather than a spread of
them. Combine several with `unionRouteAtom([...])` first.
Ticket: 420
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
unionRouteAtom, which combines several routes into one that matches wherever any memberdoes, and makes
notAtomtake that single (possibly union) route plus an options object insteadof a spread.
Needs OWNER's attention:
Plain first-match-wins is a live regression: the docs site's not-found list starts with
homeRoute(rootAtom), which matches everywhere, so the whole site would report not-found.NotOptions.exactdefaults totrue, unlike<Route exact>anduseLink({ exact }), whichdefault to
false. It has to, to preserve current behaviour — but it is the one place in thesurface where
exactdefaults the other way.BREAKING CHANGE:
notAtomno longer takes a spread of routes. Combine them withunionRouteAtom([...])first, then pass the result as the single first argument.Why
unionRouteAtom: the return type is a route atom (readable for aRouteReturn, writableto navigate, usable as a
parent), so it takes theRouteAtomsuffix;unionnames what it doeswithout implying a boolean like
notAtom's bare form does.