This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-09
Channels
- # announcements (12)
- # beginners (159)
- # boot (3)
- # calva (41)
- # cider (48)
- # clara (2)
- # clj-kondo (8)
- # cljdoc (8)
- # clojure (70)
- # clojure-dev (10)
- # clojure-europe (2)
- # clojure-losangeles (1)
- # clojure-nl (12)
- # clojure-spec (7)
- # clojure-uk (63)
- # clojurescript (24)
- # cursive (24)
- # datomic (22)
- # expound (17)
- # figwheel (1)
- # fulcro (176)
- # graphql (23)
- # jobs (9)
- # jobs-discuss (56)
- # kaocha (1)
- # mount (3)
- # nyc (1)
- # off-topic (91)
- # onyx (3)
- # overtone (4)
- # pathom (3)
- # pedestal (1)
- # re-frame (11)
- # reitit (19)
- # ring (8)
- # shadow-cljs (16)
- # test-check (5)
- # testing (2)
- # tools-deps (20)
- # vim (9)
i'm using reitit.frontend.easy
like so:
(rfe/start!
(rf/router routes)
(fn [route] ...))
and in another namespace i'd like to do the equivalent:
(r/match-by-name router ::order {:id 2})
but i don't have a handle on the router passed to rfe/start!
. given that RFE is stateful, can the router be referenced somehow, or do i need to def the result of rf/router
on my own?i think you're right. i took a look through the source code but wasn't sure if the router was stored in another namespace.
aahhh. i wasn't sure if the history atom was the same as the result of calling rf/router
. cool.
rf/router
creates a new router. rfe
namespace manages the state for you. You pass in the router on rfe/start
and it creates the history thing with the router.
It’s probably just a matter of taste whether you want to def
the router your self or access it through the derefed history object. 🙂
cool, i'm fine with that 🙂 just wasn't sure if there was a "batteries included" reitit.frontend.easy
version of r/match-by-name
that worked like rfe/href
on to my next question! when using rfe/href
is there a way to replace the current history rather than push onto it? i understand that rfe has different functions for push vs replace, but i'd like to define that when building a href
@joshkh Currently, no. It could be implemented for HTML5 router, e.g. by reading some data-
attribute in a
which would change the call here: https://github.com/metosin/reitit/blob/master/modules/reitit-frontend/src/reitit/frontend/history.cljs#L106 BUT I don't think this makes sense, href
is used when user clicks an anchor, and clicking anchors should always push the new state to history.
that's sound logic, and thanks for the details. i'm just being lazy because i (think i remember?) reading that on-click isn't compatible with some mobile platforms that otherwise require a tap event.
If you really need this, you can easily call rfe/replace-state
in :on-click
handler
Or if you can find example of "popular" JS routing library that provides this for anchors, I could revise my opinion