Fork me on GitHub
Clément Ronzon00:12:09

Hey guys, I couldn't find a way to programmatically change the url of the page from an effect handler, I'm sure there might be an easy way... anyone knows? (I'm using pushy and bidi for routing) [answer in thread please]


It's right there in the pushy documentation: The "Bidi" section has a set-page! function - just call it within an effect.

Clément Ronzon14:12:20

Thank you @U2FRKM4TW I am using the db to store the current route. When I try to change the route, it correctly displays the corresponding panel, but it won't change the url.

Clément Ronzon14:12:44

I believe I have to use set-token! to change the url (see but I can't add an event to control it since it would create a circular reference.


No idea, sorry. FWIW I'm using kee-frame myself that ties it all together itself.

Clément Ronzon14:12:42

I've seen this implementation ( that saves the pushy instance into the db itself making it accessible from any event, eliminating the circular reference. I have to try it.

Clément Ronzon14:12:07

Thanks @U2FRKM4TW, I'll check kee-frame.

Clément Ronzon14:12:34

Actually, thank you so much @U2FRKM4TW, looking at kee-frame's code I found how they did it! (and it's pretty simple actually) /src/kee_frame/router.cljc:88

(rf/reg-fx :navigate-to goto)
And /src/kee_frame/router.cljc:28
(defn goto [data]
  (navigate! @state/navigator (url data)))
tl;dr; With such an unqualified event ID we don't have to worry about the circular reference issue anymore.


You don't have to worry about circular dependencies with fully qualified keywords as well - you can just avoid using an alias and instead spell out the whole keyword with its namespace.

Clément Ronzon15:12:52

A fully qualified keyword gives me a compilation error:

68 |           [:dispatch [::spui.routes/navigate-to route]]]}))
spui/events.cljs [line 68, col 48] Invalid keyword: ::spui.routes/navigate-to.
Did I write it wrong? spui.routes:
(re-frame/reg-event-fx ::navigate-to navigate-to)


Try :spui.routes/navigate-to instead of ::spui.routes/navigate-to (single colon). Double colon expects a namespace alias.

Clément Ronzon22:01:36

Excellent! Thank you!!


does re-frame-10x work with reagent 1.0.0? I'm not sure whether there's something wrong with my config or whether it's a versioning problem - it seems like when i recompile, the page occasionally fails to load


I have an action I’d like to take when two different things (an API access token and a GPS location) become available in my app db. This would be easy enough if it was a component—I would simply have the component subscribe to both app db keys and everything would be good. But in this case, the action has no user-visible effects (it simply adds more information to the app db by talking to the API). So I’m looking for something like “fire an event when these two events have fired”. Suggestions gratefully received!


If it's indeed "if seen eventA and eventB, fire eventC", then you can use If it's "when valueA and valueB are set, fire eventC", then you can use a global interceptor.


Thanks! My situation is more like: • If eventA is fired, and valueB is already in the app db, go ahead (using valueB in the handling of eventA). • If eventA is fired, but valueB isn’t (yet) in the app db, wait until it is and then handle eventA. (if that makes sense?)


I imagine that I can transform it into one of the two cases you mention above 👍

👍 3