mirror of
https://github.com/penpot/penpot.git
synced 2025-05-28 01:06:12 +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)
|
(json/->js params)
|
||||||
params))
|
params))
|
||||||
|
|
||||||
(defn- create-file*
|
(defn- create-file-api
|
||||||
[file]
|
[file]
|
||||||
(let [state* (volatile! file)]
|
(let [state* (volatile! file)
|
||||||
(obj/reify {:name "File"}
|
api (obj/reify {:name "File"}
|
||||||
:id
|
:id
|
||||||
{:get #(dm/str (:id @state*))}
|
{:get #(dm/str (:id @state*))}
|
||||||
|
|
||||||
|
@ -238,13 +238,18 @@
|
||||||
(fn []
|
(fn []
|
||||||
(-> @state*
|
(-> @state*
|
||||||
(d/without-qualified)
|
(d/without-qualified)
|
||||||
(json/->js))))))
|
(json/->js))))]
|
||||||
|
|
||||||
|
(specify! api
|
||||||
|
cljs.core/IDeref
|
||||||
|
(-deref [_]
|
||||||
|
(d/without-qualified @state*)))))
|
||||||
|
|
||||||
(defn create-file
|
(defn create-file
|
||||||
[params]
|
[params]
|
||||||
(try
|
(try
|
||||||
(let [params (-> params json/->clj fb/decode-file)
|
(let [params (-> params json/->clj fb/decode-file)
|
||||||
file (fb/create-file params)]
|
file (fb/create-file params)]
|
||||||
(create-file* file))
|
(create-file-api file))
|
||||||
(catch :default cause
|
(catch :default cause
|
||||||
(handle-exception cause))))
|
(handle-exception cause))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue