reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
rgm 2020-09-15T01:07:22.124400Z

So I thought I’d come up with a clever way to share one route tree between frontend and backend, per https://cljdoc.org/d/metosin/reitit/0.5.5/doc/advanced/shared-routes. (Buckle up … there’s gonna be a lot going on here). Like the example, my route tree is all keywords, and my expander fn leans on a multimethod dispatched on the route keyword to retrieve route data. This lets me swap in different route data in clj and cljs in an orderly way. A bit boilerplate-y but has the advantage of regularity and obviousness. I also default this route data multimethod to nil (no route data at all). I was hoping this would effectively filter the route tree at expansion time. Use case: I want the backend to feed out an SPA host page on a few routes, but also have HTML5 in-browser routing on those routes, without having to keep two separate tree definitions in sync, and have it be pretty obvious while I’m developing when a given route will either exit the SPA and move to a server-rendered page, or stay within the SPA. Sadly, I now see that the routes still exist for the frontend.easy router, and participate in match-by-path, and so therefore default ignore-anchor-click? is keeping me in the SPA even for backend routes. I can provide my own implementation and fix this, but … I’m so generally impressed by Reitit it struck me that I must be doing this wrong, and there’s a contemplated way to handle this idea of smoothly moving between SPAs and server-rendered pages. (I looked at the :coerce and :compile options to reitit.core/router but nothing obvious came out of my experiments).