Fork me on GitHub
#reitit
<
2020-06-17
>
fmn06:06:58

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 ....}]]

ikitommi07:06:54

@funyako.funyao156 yes. it’s just route data and accumulates normally (using meta-merge)

ikitommi07:06:13

the last (nearest to the leaf) wins by default, but you can use meta-merge hints to change how the merging works.

fmn09:06:37

Thank you. Always got a fast response from the Metosin guys 😉

👍 3
ivana10:06:43

You are lucky, instead of me 🙂 But I'v found a solution by myself with nested routes & merging data

👍 3
plins15:06:29

is there a way to keep response coercion but do not throw if it fails?

plins15:06:09

a log message would be enough for me

orestis15:06:31

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?

valtteri17:06:04

Do you want to update the address bar according to some app state changes or something else?

valtteri17:06:22

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

orestis17:06:01

Yeah, essentially reflecting the UI state in the address bar so that people can share URLs.

orestis17:06:37

The issue is that it’s not all UI state, just that that describes the underlying DB query.

orestis17:06:14

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.

orestis17:06:58

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.

valtteri17:06:46

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

valtteri17:06:07

I mean backend db

orestis17:06:38

Yeah that’s the alternative. In the end there is also a limit on how big a url can be.