From db36c617bfb7f5c6f1da00961432f6078eb31210 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 26 Feb 2017 20:45:06 +0100 Subject: [PATCH] Convert some events from reify to deftype. --- frontend/src/uxbox/main/data/shapes.cljs | 34 +++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/frontend/src/uxbox/main/data/shapes.cljs b/frontend/src/uxbox/main/data/shapes.cljs index 10d750eb2f..d2a01af58a 100644 --- a/frontend/src/uxbox/main/data/shapes.cljs +++ b/frontend/src/uxbox/main/data/shapes.cljs @@ -109,15 +109,21 @@ [data] (AddShape. data)) +;; --- Delete Shape + +(deftype DeleteShape [id] + udp/IPageUpdate + ptk/UpdateEvent + (update [_ state] + (println "DeleteShape$update" id) + (let [shape (get-in state [:shapes id])] + (impl/dissoc-shape state shape)))) + (defn delete-shape "Remove the shape using its id." [id] - (reify - udp/IPageUpdate - ptk/UpdateEvent - (update [_ state] - (let [shape (get-in state [:shapes id])] - (impl/dissoc-shape state shape))))) + {:pre [(uuid? id)]} + (DeleteShape. id)) (defn update-shape "Just updates in place the shape." @@ -603,15 +609,19 @@ [] (DuplicateSelected.)) +;; --- Delete Selected + +(deftype DeleteSelected [] + ptk/WatchEvent + (watch [_ state stream] + (let [selected (get-in state [:workspace :selected])] + (rx/from-coll + (into [(deselect-all)] (map #(delete-shape %) selected)))))) + (defn delete-selected "Deselect all and remove all selected shapes." [] - (reify - ptk/WatchEvent - (watch [_ state s] - (let [selected (get-in state [:workspace :selected])] - (rx/from-coll - (into [(deselect-all)] (map #(delete-shape %) selected))))))) + (DeleteSelected.)) (deftype UpdateSelectedShapesAttrs [attrs] ptk/WatchEvent