Skip to content

Commit

Permalink
Story ID: develop
Browse files Browse the repository at this point in the history
patch to bungled fix to tempid handling in callbacks
  • Loading branch information
awkay committed May 20, 2016
1 parent 5c76276 commit 09e28b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
13 changes: 3 additions & 10 deletions src/untangled/client/impl/application.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,12 @@
(when has-mutations?
(enqueue queue payload))))

(defn- action-with-args
"Allows optional arguments to be passed in first so we can use
this function with `partial` to generate a callback that takes just
a response and passes both arguments and response to the action"
[action args resp]
(apply action (apply conj [resp] args)))

(defn enqueue-reads [{:keys [queue reconciler networking]}]
(let [parallel-payload (f/mark-parallel-loading reconciler)
fetch-payload (f/mark-loading reconciler)]
(doseq [{:keys [query on-load on-error callback-args]} parallel-payload]
(let [on-load' (partial action-with-args on-load callback-args)
on-error' (partial action-with-args on-error callback-args)]
(let [on-load' #(on-load % callback-args)
on-error' #(on-error % callback-args)]
(real-send networking query on-load' on-error')))
(when fetch-payload
(enqueue queue (assoc fetch-payload :networking networking)))))
Expand All @@ -68,7 +61,7 @@
[{:keys [networking queue response-channel]}]
(letfn [(make-process-response [action callback-args]
(fn [resp]
(try (action-with-args action callback-args resp)
(try (action resp callback-args)
(finally (go (async/>! response-channel :complete))))))]
(go
(loop [payload (async/<! queue)]
Expand Down
8 changes: 4 additions & 4 deletions src/untangled/client/impl/data_fetch.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
{:ui/fetch-state (set-loading! item)}))
(swap! state assoc :om.next/ready-to-load [])
(om/force-root-render! reconciler)
{:query (full-query items-to-load)
:on-load (loaded-callback reconciler)
:on-error (error-callback reconciler)
:callback-args [items-to-load]})))
{:query (full-query items-to-load)
:on-load (loaded-callback reconciler)
:on-error (error-callback reconciler)
:callback-args items-to-load})))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Testing API, used to write tests against specific data states
Expand Down

0 comments on commit 09e28b4

Please sign in to comment.