0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

Add finish event for plugins

This commit is contained in:
alonso.torres 2024-05-23 13:37:26 +02:00 committed by Andrey Antukh
parent 5af77af6da
commit 3e6d3a2306
2 changed files with 15 additions and 0 deletions

View file

@ -52,6 +52,10 @@
[_ type callback]
(events/add-listener type callback))
(removeListener
[_ listener-id]
(events/remove-listener listener-id))
(getViewport
[_]
(viewport/create-proxy))

View file

@ -14,6 +14,14 @@
(defmulti handle-state-change (fn [type _] type))
(defmethod handle-state-change "finish"
[_ old-val new-val]
(let [old-file-id (:current-file-id old-val)
new-file-id (:current-file-id new-val)]
(if (and (some? old-file-id) (nil? new-file-id))
(str old-file-id)
::not-changed)))
(defmethod handle-state-change "filechange"
[_ old-val new-val]
(let [old-file (:workspace-file old-val)
@ -72,3 +80,6 @@
;; return the generated key
key))
(defn remove-listener
[key]
(remove-watch st/state key))