Skip to content

Commit

Permalink
refactor: simplify by c.m/run-background-task
Browse files Browse the repository at this point in the history
  • Loading branch information
RCmerci committed Dec 11, 2024
1 parent 6cc6a20 commit 8327ad5
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/main/frontend/worker/rtc/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -387,22 +387,12 @@
;;; ================ API (ends) ================

;;; subscribe state ;;;
(c.m/run-background-task
:subscribe-state
(m/reduce
(fn [_ v] (worker-util/post-message :rtc-sync-state v))
create-get-state-flow))

(defonce ^:private *last-subscribe-canceler (atom nil))
(defn- subscribe-state
[]
(when-let [canceler @*last-subscribe-canceler]
(canceler)
(reset! *last-subscribe-canceler nil))
(let [cancel (c.m/run-task
(m/reduce
(fn [_ v] (worker-util/post-message :rtc-sync-state v))
create-get-state-flow)
:subscribe-state)]
(reset! *last-subscribe-canceler cancel)
nil))

(subscribe-state)

(comment
(do
Expand Down

0 comments on commit 8327ad5

Please sign in to comment.