Fork me on GitHub
#re-frame
<
2019-08-26
>
tianshu13:08:13

anyone use re-frame with secretary as router?

scknkkrer13:08:51

I’m using now. But mostly not idiomatic.

tianshu13:08:07

@scknkkrer great, how do you change the route in re-frame event?

tianshu13:08:05

I know basically I can use hyper link with href set like "#/some-path", but (.pushState js/history nil nil "#/some-path") seems won't trigger the route change

scknkkrer13:08:09

I can suggest something but I’m not an expert on idiomatic usage routing libraries on Re-Frame.

scknkkrer13:08:08

(re-frame.core/reg-fx
  :app/set-screen!
  (fn [page-url]
    (set! js/window.location.href page-url)))

scknkkrer13:08:11

Defining an Effect for this job, looked nice to me. Maybe I’m wrong. But, I’m sure there so many of us use re-frame professionally.

scknkkrer13:08:17

They can correct me, and you.

tianshu13:08:44

do you use #?

scknkkrer13:08:13

Oh, after defining the Effect just call it from Effectful Event Handler.

scknkkrer13:08:43

I think you should use it. Unless, you have an isomorphic application.

tianshu13:08:08

emm, I can set the whole url, because the url of my application is like

scknkkrer14:08:43

@doglooksgood, oh, your application is isomorphic.

scknkkrer14:08:27

So, I think you can use it like this way.

scknkkrer15:08:18

Only when I compile with :optimization :advanced flag.

scknkkrer15:08:25

I’m using webpack to bundle my dependencies from NPM.

scknkkrer16:08:50

@U071CG4QY,

[{:file "app/prod/js/bundle.js"
                                                               :provides ["react" "react-dom"],
                                                               :requires ["react" "react-dom"]
                                                               :global-exports {react React
                                                                                react-dom ReactDOM}}]
I’m using this vector in my project.clj file. I thought it looks good. According the link you shared, my configuration has to solve the problem.

scknkkrer16:08:56

But, it doesn’t.

alpox16:08:23

@doglooksgood I hear some people use https://github.com/kibu-australia/pushy for changing the route with html pushstate - but I'm not sure if it is what you want

tianshu17:08:31

thanks, I will take a look.

Daw-Ran Liou17:08:59

I took @jacek.schae’s learn-re-frame course and learned to use bidi with pushy for routing. The link here: https://github.com/jacekschae/learn-re-frame-course-files/blob/master/increments/complete/src/app/router.cljs

👍 4
Daw-Ran Liou20:08:05

Looks awesome! Thanks