♻️ Remove rx/first calls and replaced by safer rx/take 1

This commit is contained in:
alonso.torres 2022-02-03 18:30:25 +01:00
parent b8f2f3e34d
commit fbbb079599
6 changed files with 9 additions and 9 deletions

View file

@ -196,7 +196,7 @@
(->> stream (->> stream
(rx/filter #(= ::dwc/index-initialized %)) (rx/filter #(= ::dwc/index-initialized %))
(rx/first) (rx/take 1)
(rx/map #(file-initialized bundle))))))))) (rx/map #(file-initialized bundle)))))))))
ptk/EffectEvent ptk/EffectEvent
@ -1636,7 +1636,7 @@
(->> (rx/concat paste-transit-str (->> (rx/concat paste-transit-str
paste-plain-text-str paste-plain-text-str
paste-image-str) paste-image-str)
(rx/first) (rx/take 1)
(rx/catch (rx/catch
(fn [err] (fn [err]
(js/console.error "Clipboard error:" err) (js/console.error "Clipboard error:" err)

View file

@ -219,7 +219,7 @@
;; Hide the modal if the stop event is emitted ;; Hide the modal if the stop event is emitted
(->> stop? (->> stop?
(rx/first) (rx/take 1)
(rx/map #(md/hide)))))) (rx/map #(md/hide))))))
ptk/UpdateEvent ptk/UpdateEvent

View file

@ -74,7 +74,7 @@
(rx/of (handle-drawing type)) (rx/of (handle-drawing type))
(->> stream (->> stream
(rx/filter (ptk/type? ::common/handle-finish-drawing) ) (rx/filter (ptk/type? ::common/handle-finish-drawing) )
(rx/first) (rx/take 1)
(rx/map #(fn [state] (update state :workspace-drawing dissoc :lock))))))))))) (rx/map #(fn [state] (update state :workspace-drawing dissoc :lock)))))))))))
(defn handle-drawing (defn handle-drawing

View file

@ -70,7 +70,7 @@
(let [opacity-events (->> stream ;; Stop buffering after time without opacities (let [opacity-events (->> stream ;; Stop buffering after time without opacities
(rx/filter (ptk/type? ::pressed-opacity)) (rx/filter (ptk/type? ::pressed-opacity))
(rx/buffer-time 600) (rx/buffer-time 600)
(rx/first) (rx/take 1)
(rx/map #(set-opacity (calculate-opacity (map deref %)))))] (rx/map #(set-opacity (calculate-opacity (map deref %)))))]
(rx/concat (rx/concat
(rx/of (set-opacity (calculate-opacity [opacity]))) ;; First opacity is always fired (rx/of (set-opacity (calculate-opacity [opacity]))) ;; First opacity is always fired

View file

@ -523,7 +523,7 @@
(watch [_ _ stream] (watch [_ _ stream]
(->> stream (->> stream
(rx/filter (ptk/type? ::dws/duplicate-selected)) (rx/filter (ptk/type? ::dws/duplicate-selected))
(rx/first) (rx/take 1)
(rx/map #(start-move from-position)))))) (rx/map #(start-move from-position))))))
(defn- start-move (defn- start-move
@ -612,7 +612,7 @@
(rx/filter #(= direction (deref %)))) (rx/filter #(= direction (deref %))))
stopper (->> move-events stopper (->> move-events
(rx/debounce 100) (rx/debounce 100)
(rx/first)) (rx/take 1))
scale (if shift? (gpt/point (:big nudge)) (gpt/point (:small nudge))) scale (if shift? (gpt/point (:big nudge)) (gpt/point (:small nudge)))
mov-vec (gpt/multiply (get-displacement direction) scale)] mov-vec (gpt/multiply (get-displacement direction) scale)]

View file

@ -82,7 +82,7 @@
:frame-id frame-id :frame-id frame-id
:axis coord :axis coord
:ranges [[(- value 0.5) (+ value 0.5)]]}) :ranges [[(- value 0.5) (+ value 0.5)]]})
(rx/first) (rx/take 1)
(rx/map (remove-from-snap-points remove-snap?)) (rx/map (remove-from-snap-points remove-snap?))
(rx/map flatten-to-points)))) (rx/map flatten-to-points))))
@ -98,7 +98,7 @@
:frame-id frame-id :frame-id frame-id
:axis coord :axis coord
:ranges ranges}) :ranges ranges})
(rx/first) (rx/take 1)
(rx/map (remove-from-snap-points remove-snap?)) (rx/map (remove-from-snap-points remove-snap?))
(rx/map (get-min-distance-snap points coord))))) (rx/map (get-min-distance-snap points coord)))))