Closed upsiflu closed 11 months ago
The API changes in ce5ecd7 represent a minimal and, I assume, most conventional approach. No invariants were enforced though.
If you want to enforce route invariants, combine this library with something like elm-land, elm-pages, elm-app-url etc. -> Future focus.
Use case: In the
Moving across thresholds
app, we are re-routing paths to the closest match in a directory.Invariants: I. The Url is the single source of truth, so a
Less.Application
will not re-route to the matching route. II. It must remain possible to create routes implicitly by adding pages withGoTo
andBounce
without the need to update the matching algorithm. Every page can be reached. III. Two pages with different paths are never shown in parallel -- unless one is the parent "directory" of the other. IV. Every location is a valid location. I.e. the page shown will never depend on the page shown before.Questions: Where should the provision of the aforementioned directory or matching algorithm happen? (a) In the selection of a
Layout
(b) AtmapDocument
with a parametermatchLocation
orsanitizePath
or the like (c) In the creation of anApplication
, with a functionmapState
(+ Link.mapLocation)How involved should
Less
be in the pathfinding?Path -> Path
or "match fuzzy location":Location -> Location
String -> Location -> Bool
; replaces the default match functionLink.stateContainsLocation
Route
type instead of a string in the link definitionsGoTo
s in the Ui are accumulated and folded for the closest match. Edge cases such as "/parent/child" implicitly matching "/parent" (but not "/") must be covered.Api: