Fork me on GitHub

i'm using reitit.frontend.easy like so:

  (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?


At least I’m defing the router


AFAIK nothing in rfe is exposing ref to the router


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.


thanks for the help!


Heh, actually you can get the router like this (:router @rfe/history)


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. 🙂


definitely 🙂


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


It could be probably implemented quite trivially


for sure. i'm just partial to reducing my defs.


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: 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


Hi all. I am currently trying to send an arraybuffer to an api stood up by reitit. Obviously, it is barfing while trying to parse the params in body. What is the correct way to deal with this??