|
1 | 1 | (ns frontend.worker.rtc.core
|
2 | 2 | "Main(use missionary) ns for rtc related fns"
|
3 | 3 | (:require [frontend.common.missionary-util :as c.m]
|
| 4 | + [frontend.worker.device :as worker-device] |
4 | 5 | [frontend.worker.rtc.asset :as r.asset]
|
5 | 6 | [frontend.worker.rtc.client :as r.client]
|
6 | 7 | [frontend.worker.rtc.client-op :as client-op]
|
|
16 | 17 | [logseq.common.config :as common-config]
|
17 | 18 | [logseq.db :as ldb]
|
18 | 19 | [malli.core :as ma]
|
19 |
| - [missionary.core :as m] |
20 |
| - [frontend.worker.device :as worker-device]) |
| 20 | + [missionary.core :as m]) |
21 | 21 | (:import [missionary Cancelled]))
|
22 | 22 |
|
23 | 23 | (def ^:private rtc-state-schema
|
|
306 | 306 | :block-uuids [block-uuid]
|
307 | 307 | :graph-uuid graph-uuid}))))
|
308 | 308 |
|
309 |
| -(def ^:private create-get-state-flow |
| 309 | +(def ^:private create-get-state-flow* |
310 | 310 | (let [rtc-loop-metadata-flow (m/watch *rtc-loop-metadata)]
|
311 | 311 | (m/ap
|
312 | 312 | (let [{rtc-lock :*rtc-lock :keys [repo graph-uuid user-uuid rtc-state-flow *rtc-auto-push? *online-users]}
|
|
331 | 331 | (rtc-log-and-state/create-remote-t-flow graph-uuid))))
|
332 | 332 | (catch Cancelled _))))))
|
333 | 333 |
|
| 334 | +(def ^:private create-get-state-flow (c.m/throttle 300 create-get-state-flow*)) |
| 335 | + |
334 | 336 | (defn new-task--get-debug-state
|
335 | 337 | []
|
336 | 338 | (m/reduce {} nil (m/eduction (take 1) create-get-state-flow)))
|
|
415 | 417 | (def a (atom 1))
|
416 | 418 | (def f1 (m/watch a))
|
417 | 419 | (def f2 (create-pull-remote-updates-flow 5000 f1))
|
418 |
| - (def cancel (c.m/run-task (m/reduce (fn [_ v] (prn :v v)) f2) :xxx)))) |
| 420 | + (def cancel (c.m/run-task (m/reduce (fn [_ v] (prn :v v)) f2) :xxx))) |
| 421 | + |
| 422 | + (defn sleep-emit [delays] |
| 423 | + (m/ap (let [n (m/?> (m/seed delays)) |
| 424 | + r (m/? (m/sleep n n))] |
| 425 | + (prn :xxx r (t/now)) |
| 426 | + r))) |
| 427 | + |
| 428 | + (def cancel |
| 429 | + ((->> (m/sample vector |
| 430 | + (m/latest identity (m/reductions {} 0 (sleep-emit [1000 1 2]))) |
| 431 | + (sleep-emit [2000 3000 1000])) |
| 432 | + (m/reduce (fn [_ v] (prn :v v)))) prn prn))) |
0 commit comments