💄 Minor naming changes.

This commit is contained in:
Andrey Antukh 2020-01-09 15:01:14 +01:00
parent 733bf7f4fb
commit 9af76ad86c

View file

@ -50,7 +50,7 @@
;; --- Protocols ;; --- Protocols
(defprotocol IAsyncChange) (defprotocol IBatchedChange)
;; --- Declarations ;; --- Declarations
@ -61,7 +61,7 @@
(declare handle-page-snapshot) (declare handle-page-snapshot)
(declare shapes-changes-commited) (declare shapes-changes-commited)
(declare commit-changes) (declare commit-changes)
(declare commit-async-changes) (declare commit-batched-changes)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Websockets Events ;; Websockets Events
@ -257,9 +257,9 @@
(ptk/type? ::initialize-page %)) (ptk/type? ::initialize-page %))
stream)] stream)]
(->> stream (->> stream
(rx/filter #(satisfies? IAsyncChange %)) (rx/filter #(satisfies? IBatchedChange %))
(rx/debounce 500) (rx/debounce 500)
(rx/map (constantly commit-async-changes)) (rx/map (constantly commit-batched-changes))
(rx/finalize #(prn "FINALIZE" %)) (rx/finalize #(prn "FINALIZE" %))
(rx/take-until stoper)))))) (rx/take-until stoper))))))
@ -672,7 +672,7 @@
(s/assert ::us/uuid id) (s/assert ::us/uuid id)
(s/assert ::shape-attrs attrs) (s/assert ::shape-attrs attrs)
(ptk/reify ::update-shape (ptk/reify ::update-shape
IAsyncChange IBatchedChange
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(let [shape-old (get-in state [:workspace-data :shapes-by-id id]) (let [shape-old (get-in state [:workspace-data :shapes-by-id id])
@ -680,7 +680,7 @@
diff (d/diff-maps shape-old shape-new)] diff (d/diff-maps shape-old shape-new)]
(-> state (-> state
(assoc-in [:workspace-data :shapes-by-id id] shape-new) (assoc-in [:workspace-data :shapes-by-id id] shape-new)
(update ::async-changes (fnil conj []) (into [:mod-shape id] diff))))))) (update ::batched-changes (fnil conj []) (into [:mod-shape id] diff)))))))
;; --- Update Page Options ;; --- Update Page Options
@ -688,7 +688,7 @@
[opts] [opts]
(s/assert ::cp/options opts) (s/assert ::cp/options opts)
(ptk/reify ::update-options (ptk/reify ::update-options
IAsyncChange IBatchedChange
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(let [opts-old (get-in state [:workspace-data :options]) (let [opts-old (get-in state [:workspace-data :options])
@ -696,7 +696,7 @@
diff (d/diff-maps opts-old opts-new)] diff (d/diff-maps opts-old opts-new)]
(-> state (-> state
(assoc-in [:workspace-data :options] opts-new) (assoc-in [:workspace-data :options] opts-new)
(update ::async-changes (fnil conj []) (into [:mod-opts] diff))))))) (update ::batched-changes (fnil conj []) (into [:mod-opts] diff)))))))
;; --- Update Selected Shapes attrs ;; --- Update Selected Shapes attrs
@ -941,10 +941,10 @@
diff (d/diff-maps shape-old shape-new)] diff (d/diff-maps shape-old shape-new)]
(-> state (-> state
(assoc-in [:workspace-data :shapes-by-id id] shape-new) (assoc-in [:workspace-data :shapes-by-id id] shape-new)
(update ::async-changes (fnil conj []) (into [:mod-shape id] diff)))))] (update ::batched-changes (fnil conj []) (into [:mod-shape id] diff)))))]
(ptk/reify ::materialize-temporal-modifier-in-bulk (ptk/reify ::materialize-temporal-modifier-in-bulk
IAsyncChange IBatchedChange
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(reduce process-shape state ids))))) (reduce process-shape state ids)))))
@ -968,12 +968,12 @@
(->> (rp/mutation :update-project-page params) (->> (rp/mutation :update-project-page params)
(rx/map shapes-changes-commited)))))) (rx/map shapes-changes-commited))))))
(def commit-async-changes (def commit-batched-changes
(ptk/reify ::commit-async-changes (ptk/reify ::commit-batched-changes
ptk/WatchEvent ptk/WatchEvent
(watch [_ state stream] (watch [_ state stream]
(let [changes (::async-changes state)] (let [changes (::batched-changes state)]
(rx/of #(dissoc % ::async-changes) (rx/of #(dissoc % ::batched-changes)
(commit-changes changes)))))) (commit-changes changes))))))
(s/def ::shapes-changes-commited (s/def ::shapes-changes-commited