mirror of
https://github.com/penpot/penpot.git
synced 2025-05-25 21:36:09 +02:00
✨ Add the ability to deref internal state on library file instance
This commit is contained in:
parent
dc7e53881a
commit
4c487834f0
1 changed files with 166 additions and 161 deletions
|
@ -58,10 +58,10 @@
|
|||
(json/->js params)
|
||||
params))
|
||||
|
||||
(defn- create-file*
|
||||
(defn- create-file-api
|
||||
[file]
|
||||
(let [state* (volatile! file)]
|
||||
(obj/reify {:name "File"}
|
||||
(let [state* (volatile! file)
|
||||
api (obj/reify {:name "File"}
|
||||
:id
|
||||
{:get #(dm/str (:id @state*))}
|
||||
|
||||
|
@ -238,13 +238,18 @@
|
|||
(fn []
|
||||
(-> @state*
|
||||
(d/without-qualified)
|
||||
(json/->js))))))
|
||||
(json/->js))))]
|
||||
|
||||
(specify! api
|
||||
cljs.core/IDeref
|
||||
(-deref [_]
|
||||
(d/without-qualified @state*)))))
|
||||
|
||||
(defn create-file
|
||||
[params]
|
||||
(try
|
||||
(let [params (-> params json/->clj fb/decode-file)
|
||||
file (fb/create-file params)]
|
||||
(create-file* file))
|
||||
(create-file-api file))
|
||||
(catch :default cause
|
||||
(handle-exception cause))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue