can just swap directly into view-data here, no need for a cursor

i think i was originally worried that swapping into view-data directly
would cause unnecessary component re-renders, but that should not ever
happen because application code should not be dereferencing view-data
directly (should always be using cursors).
This commit is contained in:
Gered 2016-05-30 18:59:32 -04:00
parent 391e8fe5af
commit 38dee6ee8e

View file

@ -31,10 +31,13 @@
(r/cursor view-data [view-sig :data])) (r/cursor view-data [view-sig :data]))
(defn- handle-view-refresh [[view-sig data]] (defn- handle-view-refresh [[view-sig data]]
(let [cursor (r/cursor view-data [view-sig])] (swap! view-data
(swap! cursor (fn [view-data]
#(assoc % :loading false (if (contains? view-data view-sig)
:data data)))) (update-in view-data [view-sig] assoc
:loading false
:data data)
view-data))))
(defn subscribed? (defn subscribed?
"Returns true if we are currently subscribed to the specified view." "Returns true if we are currently subscribed to the specified view."