This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-05
Channels
- # announcements (23)
- # babashka (23)
- # beginners (48)
- # calva (41)
- # clj-kondo (41)
- # cljs-dev (75)
- # cljsrn (5)
- # clojure (85)
- # clojure-europe (46)
- # clojure-nl (2)
- # clojure-spec (70)
- # clojure-uk (4)
- # clojurescript (52)
- # core-async (2)
- # cursive (16)
- # datahike (2)
- # datomic (4)
- # emacs (15)
- # figwheel-main (2)
- # fulcro (5)
- # gratitude (5)
- # helix (14)
- # introduce-yourself (2)
- # jackdaw (13)
- # keyboards (2)
- # lsp (8)
- # luminus (5)
- # malli (3)
- # meander (12)
- # nextjournal (52)
- # off-topic (19)
- # other-languages (1)
- # overtone (3)
- # pathom (4)
- # podcasts-discuss (1)
- # re-frame (6)
- # reitit (1)
- # releases (2)
- # ring (3)
- # sci (22)
- # shadow-cljs (3)
- # specter (1)
- # testing (3)
- # tools-deps (100)
- # uncomplicate (2)
Beginner re-frame + bidi router question: How do I navigate user to different route after successfully submitting post? In routes.cljs I see "dispatch" and "navigate" (which I assume are used for this task) but I am not sure how to use them.
What is routes.cljs
, where does it come from?
But in general, bidi is a router - it matches URLs to IDs/parameters and vice versa. Navigating to specific URLs is an independent concept.
E.g. kee-frame
uses https://github.com/venantius/accountant for that.
routes.cljs is a file that was automatically setup for me when using bidi in combinatio with re-frame and where routes for my app are defined. My problem is I don't know how to redirect user to one of those routes after, say, successful post submission to backend api.
So that's an artifact created by the particular template you used - not really related to bidi or re-frame themselves.
> I don't know how to redirect user to one of those routes
You need to have a URL - bidi can help with that.
You also need to set the current browser location to that URL without a page refresh - bidi cannot help there. As I mentioned, there are other libraries for that, like accountant
. Or you can use HTML5 history API yourself, without any libraries. You can also look at kee-frame
- the library has a decent amount of things covered, including being able to redirect users to some page with an event/effect.
Thanks, you sent me on the right path and I think I got it working. I installed re-frame with bidi + pushy and it came with a ::navigate event which is just a wrapper around pushy/set-token which sets html5 history (if I understood things right). But yeah, like I said, it seems to work. Thanks!
reitit
support HTML5 history api out of the box too.
See this example which is great: https://github.com/metosin/reitit/tree/master/examples/frontend-re-frame