diff --git a/frontend/src/app/main/data/workspace/modifiers.cljs b/frontend/src/app/main/data/workspace/modifiers.cljs index 63a4be935f..c3a13c0dba 100644 --- a/frontend/src/app/main/data/workspace/modifiers.cljs +++ b/frontend/src/app/main/data/workspace/modifiers.cljs @@ -30,6 +30,7 @@ [app.main.data.workspace.shapes :as dwsh] [app.main.data.workspace.undo :as dwu] [app.main.features :as features] + [app.main.streams :as ms] [app.render-wasm.api :as wasm.api] [app.render-wasm.shape :as wasm.shape] [beicon.v2.core :as rx] @@ -617,16 +618,16 @@ (defn set-temporary-selrect [selrect] (ptk/reify ::set-temporary-selrect - ptk/UpdateEvent - (update [_ state] - (assoc state :workspace-selrect selrect)))) + ptk/EffectEvent + (effect [_ _ _] + (rx/push! ms/workspace-selrect selrect)))) (defn set-temporary-modifiers [modifiers] (ptk/reify ::set-temporary-modifiers - ptk/UpdateEvent - (update [_ state] - (assoc state :workspace-wasm-modifiers modifiers)))) + ptk/EffectEvent + (effect [_ _ _] + (rx/push! ms/wasm-modifiers modifiers)))) (def ^:private xf:map-key (map key)) diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index a20794bfc2..c6493c9d1a 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -138,9 +138,12 @@ (ptk/reify ::finish-transform ptk/UpdateEvent (update [_ state] - (-> state - (update :workspace-local dissoc :transform :duplicate-move-started?) - (dissoc :workspace-selrect :workspace-wasm-modifiers))))) + (update state :workspace-local dissoc :transform :duplicate-move-started?)) + + ptk/EffectEvent + (effect [_ _ _] + (rx/push! ms/wasm-modifiers nil) + (rx/push! ms/workspace-selrect nil)))) ;; -- Resize -------------------------------------------------------- diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index 870e659746..01bb43a0cb 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -17,6 +17,8 @@ [app.main.data.helpers :as dsh] [app.main.data.workspace.tokens.selected-set :as dwts] [app.main.store :as st] + [app.main.streams :as ms] + [beicon.v2.core :as rx] [okulary.core :as l])) ;; ---- Global refs @@ -161,7 +163,9 @@ (l/derived :workspace-tokens st/state)) (def workspace-selrect - (l/derived :workspace-selrect st/state)) + (let [a (atom nil)] + (rx/sub! ms/workspace-selrect #(reset! a %)) + a)) ;; WARNING: Don't use directly from components, this is a proxy to ;; improve performance of selected-shapes and @@ -385,7 +389,9 @@ (l/derived :workspace-wasm-editor-styles st/state)) (def workspace-wasm-modifiers - (l/derived :workspace-wasm-modifiers st/state)) + (let [a (atom nil)] + (rx/sub! ms/wasm-modifiers #(reset! a %)) + a)) (def ^:private workspace-modifiers-with-objects (l/derived diff --git a/frontend/src/app/main/streams.cljs b/frontend/src/app/main/streams.cljs index d6ebf074b7..0cae9a246f 100644 --- a/frontend/src/app/main/streams.cljs +++ b/frontend/src/app/main/streams.cljs @@ -22,6 +22,16 @@ (or ^boolean (kbd/keyboard-event? event) ^boolean (mse/mouse-event? event))) +;; Live preview state for an interactive transform. Pushed by drag +;; events at the cadence set by upstream `rx/sample` (see +;; `transforms.cljs`); subscribed via plain atoms in `app.main.refs` so +;; updates bypass the Redux store and don't re-run unrelated lenses. +(defonce wasm-modifiers + (rx/behavior-subject nil)) + +(defonce workspace-selrect + (rx/behavior-subject nil)) + ;; --- Derived streams (defonce ^:private pointer diff --git a/frontend/src/app/main/ui/workspace/sidebar/options.cljs b/frontend/src/app/main/ui/workspace/sidebar/options.cljs index c7413af9ac..7f44c7502e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options.cljs @@ -73,7 +73,7 @@ nil))) (mf/defc shape-options* - {::mf/wrap [#(mf/throttle % 100)] + {::mf/wrap [#(mf/throttle % 200)] ::mf/private true} [{:keys [shapes shapes-with-children selected page-id file-id libraries]}] (if (= 1 (count selected))