mirror of
https://github.com/penpot/penpot.git
synced 2025-06-25 15:46:58 +02:00
📎 Add service result wrapper
Allows attach metadata to values that does not implement the IObj clojure interface.
This commit is contained in:
parent
47363d96f1
commit
2753a934aa
3 changed files with 23 additions and 5 deletions
|
@ -31,9 +31,10 @@
|
|||
|
||||
(defn- handle-response-transformation
|
||||
[response request mdata]
|
||||
(if-let [transform-fn (:transform-response mdata)]
|
||||
(p/do (transform-fn request response))
|
||||
(p/resolved response)))
|
||||
(let [response (if (sv/wrapped? response) @response response)]
|
||||
(if-let [transform-fn (:transform-response mdata)]
|
||||
(p/do (transform-fn request response))
|
||||
(p/resolved response))))
|
||||
|
||||
(defn- handle-before-comple-hook
|
||||
[response mdata]
|
||||
|
|
|
@ -11,6 +11,20 @@
|
|||
[app.common.data :as d]
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
(defrecord WrappedValue [obj]
|
||||
clojure.lang.IDeref
|
||||
(deref [_] obj))
|
||||
|
||||
(defn wrap
|
||||
([]
|
||||
(WrappedValue. nil))
|
||||
([o]
|
||||
(WrappedValue. o)))
|
||||
|
||||
(defn wrapped?
|
||||
[o]
|
||||
(instance? WrappedValue o))
|
||||
|
||||
(defmacro defmethod
|
||||
[sname & body]
|
||||
(let [[docs body] (if (string? (first body))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue