Add throttling to over-shapes-stream on viewport

This commit is contained in:
Andrey Antukh 2023-08-25 11:08:55 +02:00 committed by Andrés Moya
parent ec1c1fcd2f
commit a754d5ae3b

View file

@ -154,19 +154,20 @@
over-shapes-stream over-shapes-stream
(mf/with-memo [move-stream mod-str] (mf/with-memo [move-stream mod-str]
(rx/merge (->> (rx/merge
;; This stream works to "refresh" the outlines when the control is pressed ;; This stream works to "refresh" the outlines when the control is pressed
;; but the mouse has not been moved from its position. ;; but the mouse has not been moved from its position.
(->> mod-str (->> mod-str
(rx/observe-on :async) (rx/observe-on :async)
(rx/map #(deref last-point-ref)) (rx/map #(deref last-point-ref))
(rx/filter some?) (rx/filter some?)
(rx/merge-map query-point)) (rx/merge-map query-point))
(->> move-stream (->> move-stream
(rx/tap #(reset! last-point-ref %)) (rx/tap #(reset! last-point-ref %))
;; When transforming shapes we stop querying the worker ;; When transforming shapes we stop querying the worker
(rx/merge-map query-point))))] (rx/merge-map query-point)))
(rx/throttle 100)))]
;; Refresh the refs on a value change ;; Refresh the refs on a value change
(mf/use-effect (mf/use-effect