enhance: don't refresh when auto-save

This commit is contained in:
Tienson Qin
2021-04-18 21:33:07 +08:00
parent 6e6093b339
commit e09b777219
4 changed files with 88 additions and 62 deletions

View File

@@ -1228,14 +1228,17 @@
(defn keyname [key] (str (namespace key) "/" (name key)))
(defn batch [in max-time handler]
(defn batch [in max-time idle? handler]
(async/go-loop [buf [] t (async/timeout max-time)]
(let [[v p] (async/alts! [in t])]
(cond
(= p t)
(do
(handler buf)
(recur [] (async/timeout max-time)))
(let [timeout (async/timeout max-time)]
(if (idle?)
(do
(handler buf)
(recur [] timeout))
(recur buf timeout)))
(nil? v) ; stop
(when (seq buf)