fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
Timofey Sitnikov 2021-06-13T02:00:29.168900Z

Reviewed the links provided by @holyjak, but still struggling with getting the query parameters. Here is the snipped I am dealing with:

:will-enter        (fn [app route-params]
                        (log/info "Will enter ResetPwd" route-params)
                        (log/info "JS params" js/location.search)
                        (dr/route-immediate [:component/id :resetpwd]))
When I go to <http://localhost:3000/resetpwd?k=blah> The JS printout looks like this:
INFO [bbuptop.ui.user-auth:350] -  Will enter ResetPwd {}
INFO [bbuptop.ui.user-auth:351] -  JS params ?k=blah
Do I need to set the route-params somewhere?

Jakub Holý 2021-06-13T16:08:37.175200Z

As I mentioned before, Fulcro routing is not connected to the URL in any way (though it is designed to work with it). If you go to /some/url, nothing happens in Fulcro routing until you write some code that react to that url and calls one of the route functions (as the RAD html5 routing does).

Jakub Holý 2021-06-13T16:09:45.175400Z

So you need what you described - look at the url and js/location.search , parse it, then call fulcro routing. It is the fulcro routing url-&gt;route you are interested in. What is special about this impl is that it takes clj params maps and encodes that as a transit string so you end up with a single , unreadable param. You might not want that.

Jakub Holý 2021-06-13T16:13:00.175700Z

https://fulcro-community.github.io/main/awesome-fulcro/README.html links to @codonnell’s https://chrisodonnell.dev/posts/giftlist/routing/ which > use https://github.com/clj-commons/pushy, which wraps the HTML5 history API, and fulcro’s http://book.fulcrologic.com/#_dynamic_router to implement routing.

Timofey Sitnikov 2021-06-15T09:55:39.183900Z

@holyjak, OK, so far so good, I think I implemented mostly everything, the back button works, and entering the URL in the browser bar works. The only thing I am still wondering about, is the the will-enter (fn [app route-params] .... , where does the fn pick up the route-params, I should be able to set it somehow?

Jakub Holý 2021-06-15T14:21:46.188700Z

Those are the ones you pass to change-route

😀 1
Timofey Sitnikov 2021-06-16T10:35:07.202600Z

@holyjak, this solves my problem, thank you ...

❤️ 1
Timofey Sitnikov 2021-06-13T02:10:27.172100Z

@lgessler in :will-enter in the desfc block, you can read the params from JavaScript by reading the js/location.search parameter. Then you can parse the params string using https://github.com/fulcrologic/fulcro-rad/blob/d30b318c75b2938555ff12d617b62c21ba041957/src/main/com/fulcrologic/rad/routing/html5_history.cljc#L37 function and then you can use the params.

Timofey Sitnikov 2021-06-13T02:16:51.175Z

Unfortunately, this does not seem right. The https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/routing/html5_history.cljc is probably the right solution to use, but I have not been able to figure it out.