Hi, can we specify :coercion
(malli) per route instead of router-wide? [["/a" {:name ::a :coercion with-string-coercion ....}] ["/b" {:name ::b :coercion with-custom-coercion ....}]]
@funyako.funyao156 yes. it’s just route data and accumulates normally (using meta-merge)
the last (nearest to the leaf) wins by default, but you can use meta-merge hints to change how the merging works.
Thank you. Always got a fast response from the Metosin guys 😉
You are lucky, instead of me 🙂 But I'v found a solution by myself with nested routes & merging data
is there a way to keep response coercion but do not throw if it fails?
a log message would be enough for me
I have a match object, and a router (context is front end) and I want to add some query parameters (to reflect user interaction). I can make do by plucking things out of the match object but I’m not sure if there isn’t a better way?
Do you want to update the address bar according to some app state changes or something else?
I fiddled with something like this a while ago. I think eventually I ended up adding the params to the url somehow manually and then letting reitit controllers trigger changes to app state based on the params. I’m not sure if it’s the best way to do it but it works.. if I remember correctly. I’m not at the computer now and can’t check
Yeah, essentially reflecting the UI state in the address bar so that people can share URLs.
The issue is that it’s not all UI state, just that that describes the underlying DB query.
I would like to go through Reitit for simplicity but don’t want to hardcore the route name, and I have access to the match result.
I’m not 100% sure on the relationship between UI state and reitit controllers yet (if I want to leverage them or not), something to ponder.
Yep, encoding state in uri can be a great idea or a horrible idea.. :) If state is complex you can store it in db and create single param to retrieve it
I mean backend db
Yeah that’s the alternative. In the end there is also a limit on how big a url can be.