This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-27
Channels
- # ai (4)
- # beginners (102)
- # boot (216)
- # cider (20)
- # cljs-dev (9)
- # clojure (130)
- # clojure-russia (4)
- # clojure-spec (9)
- # clojure-uk (11)
- # clojurescript (59)
- # core-async (2)
- # cursive (10)
- # datomic (51)
- # figwheel (1)
- # flambo (3)
- # hoplon (2)
- # luminus (1)
- # om (17)
- # om-next (4)
- # onyx (2)
- # perun (2)
- # re-frame (79)
- # ring (5)
- # ring-swagger (9)
- # rum (3)
- # schema (3)
- # specter (9)
- # untangled (3)
- # vim (1)
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.
@lambdacoder: check this blog post. https://anmonteiro.com/2016/01/writing-om-next-reloadable-code-a-checklist/
How do I get my :send
function to be called? I have a read fn called that returns {:remote true}
- what am I missing?
@hlolli this is my component:
(defui About
static om/IQuery
(query [this]
[:page/about])
Object
(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)]
(do
(debug "-> " {:value v})
{:value v})
(do
(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
(om/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.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).
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.