Fork me on GitHub
Joseph Graham07:03:30

Is there any example project that shows how to use re-frame to fetch some stuff using ajax and display it? Re-frame has loads of docs but finding it very hard to imagine how to actually use it.

Ferdinand Beyer10:03:20

You probably want to use Look at the README for a usage example. You basically define an event for your Ajax call, use the http-xhrio effect to describe how to do the Ajax call and what events to dispatch :on-success and :on-failure, then define those events to handle the response. In your :on-success, update the db as you want, and create subscriptions with reg-sub to extract the data you want to render. This is no longer ajax-specific.


Look into the sections of the tutorial on how to deal with side effects.[1] Alternatively, you can jump straight into the docs of re-frame-http-fx[2] [1] [2]


Hi, I am new to the re-frame. I would like to know if is it fine to use component-local ratom in re-frame? Because when I use the following code (which adapted from TODOMVC)

(defn text-input
  (let [inner (r/atom "")]
    (fn [] [:input
            {:type "text",
             :value @inner,
             :on-change #(reset! inner (-> %
I always get the warning Subscribe was called outside of a reactive context.


there are no rf/subscribe calls in that function. you'll need to post code of the actual function calling rf/subscribe


Oh sorry, I thought this warning will occur everytime an atom is dereferenced. It turned out that the reason is something about re-pressed (which is enabled by re-frame template).