Fork me on GitHub

I think figwheel reloads differently for a css change and js change. If removeing :^once from the app-state atom does not do the trick, then try asking @bhauman. This effect of not remounting is most of the time for me a feature of figwheel. Try using instead lein cljsbuild auto if that helps.


How do I get my :send function to be called? I have a read fn called that returns {:remote true} - what am I missing?


@nha querying the read from a component?


@hlolli this is my component:

(defui About
  static om/IQuery
  (query [this]
  (render [this]
          (html [:div "About page"]))) 
The :default reader function gets called when the component renders:
(defmethod read :default
  [{:keys [state] :as env} key params]
  (let [st @state]
    (debug "reading " key " " params)
    (js/console.log "State : " st)
    (if-let [[_ v] (find st key)]
        (debug "-> " {:value v})
        {:value v})
        (debug "-> " {:remote true})
        {;;:value :not-found ;; NOTE: :not-found has no special meaning
         :remote true}))))
And I can see reading :page/about nil in my console. I have a :send function in the reconciler that is not called. I don’t specify a :remotes keys in the reconciler though.


I was expecting that returning {:remote true} from the read to trigger a call to the :send


yes, looking at your logic, you want to request for the data if it doesnt exist in the app state otherwise read. That's fine, but does the later case from if-let ever get evaluated, destructuring there within if-let that I've never used.


Yes exactly. I can see -> {:remote true} in the logs. My reconciler:

(def reconciler
   {:state app-state
    :parser (om/parser {:read read :mutate mutate})
    :normalize true
    :send frontend.lib.send/send}))
I was expecting frontend.lib.send/send to be called after these logs.


(Thanks for looking into this btw)


But somehow it's still kind of stuff that om takes care of, you can return a map with {:value (find @state :key) :remote true} and om wont re-read the remote as long as you dont update the query or remount the component (resulting in losing the data).


Hmm but it is not in the initial state and send is never called


your send function should run. Can't see otherwise.


Alright 🙂 thanks @hlolli I’ll restart my system just in case


do a more miniamel example, dont use :default, use defmethod read :page/about, you wouldn't want this to be default anyway if this expands.


and just return a map of :value and :remote and look at console logs if the send function is at least trying to run (or it is running and silently fails)


Yeah it is not trying to run, that was my concern 😕 thanks anyway I’ll try that


I'm not clear: should I be tacking ^:once onto all of my defuis? How do I know when it's necessary?