From a754d5ae3b628da50a536f1737e12bed1c198990 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 25 Aug 2023 11:08:55 +0200 Subject: [PATCH] :zap: Add throttling to over-shapes-stream on viewport --- .../app/main/ui/workspace/viewport/hooks.cljs | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index c8e597866..444302c33 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -154,19 +154,20 @@ over-shapes-stream (mf/with-memo [move-stream mod-str] - (rx/merge - ;; This stream works to "refresh" the outlines when the control is pressed - ;; but the mouse has not been moved from its position. - (->> mod-str - (rx/observe-on :async) - (rx/map #(deref last-point-ref)) - (rx/filter some?) - (rx/merge-map query-point)) + (->> (rx/merge + ;; This stream works to "refresh" the outlines when the control is pressed + ;; but the mouse has not been moved from its position. + (->> mod-str + (rx/observe-on :async) + (rx/map #(deref last-point-ref)) + (rx/filter some?) + (rx/merge-map query-point)) - (->> move-stream - (rx/tap #(reset! last-point-ref %)) - ;; When transforming shapes we stop querying the worker - (rx/merge-map query-point))))] + (->> move-stream + (rx/tap #(reset! last-point-ref %)) + ;; When transforming shapes we stop querying the worker + (rx/merge-map query-point))) + (rx/throttle 100)))] ;; Refresh the refs on a value change (mf/use-effect