reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
fmn 2020-06-17T06:47:58.133600Z

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

ikitommi 2020-06-17T07:55:54.134300Z

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

ikitommi 2020-06-17T07:57:13.135500Z

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

fmn 2020-06-17T09:55:37.136Z

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

👍 1
2020-06-17T10:06:43.137500Z

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

👍 1
plins 2020-06-17T15:27:29.138700Z

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

plins 2020-06-17T15:29:09.139Z

a log message would be enough for me

orestis 2020-06-17T15:54:31.141200Z

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?

valtteri 2020-06-17T17:38:04.143700Z

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

valtteri 2020-06-17T17:44:22.149300Z

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

orestis 2020-06-17T17:46:01.151Z

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

orestis 2020-06-17T17:46:37.152100Z

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

orestis 2020-06-17T17:47:14.153300Z

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.

orestis 2020-06-17T17:47:58.154700Z

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.

valtteri 2020-06-17T17:54:46.158Z

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

valtteri 2020-06-17T17:55:07.158400Z

I mean backend db

orestis 2020-06-17T17:56:38.159100Z

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