Skip to content

Commit

Permalink
configureable transit writers for shadow.remote
Browse files Browse the repository at this point in the history
  • Loading branch information
thheller committed Mar 20, 2024
1 parent c1ad1de commit 6d7d75c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/main/shadow/cljs/devtools/client/shared.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,18 @@
(when-some [runtime @runtime-ref]
(start-all-plugins! runtime)))

(defn transit-read [{::shared/keys [transit-readers] :as state} data]
(defn transit-read [{::keys [transit-readers] :as state} data]
(let [t (transit/reader :json {:handlers transit-readers})]
(transit/read t data)))

(defn transit-str [{::shared/keys [transit-writers] :as state} obj]
(defn transit-str [{::keys [transit-writers] :as state} obj]
(let [w (transit/writer :json {:handlers transit-writers})]
(transit/write w obj)))

(defn add-transit-writers! [{:keys [state-ref] :as runtime} writers]
(swap! state-ref update ::transit-writers merge writers)
runtime)

(declare interpret-actions)

(defn continue! [state]
Expand Down Expand Up @@ -365,6 +369,7 @@

(swap! state-ref assoc ::shutdown true)))


(defn init-runtime! [client-info ws-start-fn ws-send-fn ws-stop-fn]
;; in case of hot-reload or reconnect, clean up previous runtime
(when-some [runtime @runtime-ref]
Expand Down Expand Up @@ -397,8 +402,8 @@
::stale false
::plugins {}
::ws-errors 0
::shared/transit-writers {}
::shared/transit-readers {:default transit/tagged-value}
::transit-writers {}
::transit-readers {:default tagged-literal}
::ws-start-fn ws-start-fn
::ws-send-fn ws-send-fn
::ws-stop-fn ws-stop-fn)
Expand Down
3 changes: 2 additions & 1 deletion src/main/shadow/cljs/ui/db/inspect.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@
{::m/keys [tap-stream] :as db}
{:keys [offset num] :or {offset 0 num 0} :as params}]

(let [entries (count tap-stream)
(let [entries
(count tap-stream)

slice
(->> tap-stream
Expand Down
1 change: 0 additions & 1 deletion src/main/shadow/cljs/ui/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
[shadow.cljs.ui.components.common :as common]
))


(defc ui-error [err-ident]
(bind {:keys [text]}
(sg/query-ident err-ident
Expand Down

0 comments on commit 6d7d75c

Please sign in to comment.