Fork me on GitHub

This would need confirmation but I think aget should be used for arrays


and use goog.get for object


yep, use that in general. I don't think it's such a big problem for the specific case of -target -value, as those are properties of the JS events which aren't going to be renamed by the Closure Compiler. Nevertheless goog.get is probably a better default choice to use everywhere


To render a page, i need to grab some data from an API (a CMS). How would you do this? In my app I just made an event, :foo/fetch, which gets the data from the api and puts it in the db where :foo/data knows where to get it. Is this a sane way to do this?

(ns foo.views
   [re-frame.core :as rf]
   [reagent.core :as r]))

(defn foo-render [data]
  [:div data])

(defn foo-page []
  (r/with-let [_ (rf/dispatch [:foo/fetch])]
    (let [data @(rf/subscribe [:foo/data])]
      (when data [foo-render data]))))


@madstap ^^^ You are trying to emulate what you have done in React which is to "load data on mount". But that's not the way we tend to do things in re-frame. Note in particular the link to:


Yeah, I actually have no experience with react, so I've independently invented this anti-pattern all on my own 🙂


Since this is just the basic page data, maybe it would make more sense to do this fetching in my :routes/set-page handler then?


Thanks for the links, they seem to say that, yes, definitely do this stuff wherever the page change event happens. That makes sense.