rum

Simple, decomplected, isomorphic HTML UI library for Clojure and ClojureScript | 0.12.8 https://github.com/tonsky/rum/blob/gh-pages/CHANGELOG.md#0128
stephenmhopper 2018-03-25T02:32:32.000055Z

Hi everyone, I have a question that I think is fairly simple. I have an atom that holds my application state. Instead of referencing it directly from all of my components / functions, I’m passing it around as an argument. It has a key indicating whether or not the user is logged in. When routing to my logout route, I’d like to remove that value from the atom and redirect the user back to the login page. However, I’m having issues on figuring out where I should be doing this at. Does anyone have any suggestions?

stephenmhopper 2018-03-25T02:33:15.000018Z

I’m using secretary / accountant in addition to rum

stephenmhopper 2018-03-25T02:34:47.000015Z

Here’s my code snippet:

(rum/defc logout < rum/reactive [app-state-atom]
    [:div "logging out"])

(defn render-logout [app-state-atom]
  (swap! app-state-atom dissoc :token)
  (accountant/navigate! "#/login")
  (logout app-state-atom))

stephenmhopper 2018-03-25T13:22:39.000115Z

I managed to fix my issue. I had created a function that was calling rum/mount inside each of my defroute definitions. So calling secretary/dispatch! was building a brand new component and calling rum/mount. I updated my app to instead call rum/mount once at the beginning to mount a single component which uses rum/react on my app-state. This component now calls secretary/dispatch! which simply returns a partial function for creating the necessary rum component