This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-15
Channels
- # announcements (71)
- # architecture (2)
- # aws (41)
- # babashka (23)
- # beginners (80)
- # calva (26)
- # chlorine-clover (11)
- # cljfx (4)
- # cljs-dev (12)
- # clojure (78)
- # clojure-berlin (5)
- # clojure-czech (3)
- # clojure-dev (9)
- # clojure-europe (45)
- # clojure-france (16)
- # clojure-gamedev (2)
- # clojure-italy (3)
- # clojure-nl (4)
- # clojure-spec (8)
- # clojure-sweden (1)
- # clojure-uk (37)
- # clojurescript (18)
- # community-development (15)
- # conjure (30)
- # cursive (51)
- # datomic (16)
- # duct (19)
- # figwheel-main (3)
- # fulcro (23)
- # java (7)
- # jobs (2)
- # joker (10)
- # off-topic (7)
- # parinfer (1)
- # pathom (6)
- # reagent (5)
- # reitit (1)
- # remote-jobs (1)
- # sci (1)
- # shadow-cljs (55)
- # slack-help (3)
- # specter (4)
- # sql (21)
- # tools-deps (11)
- # vim (5)
- # xtdb (14)
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).