added ability to reload the bank balances automatically.

This commit is contained in:
2021-10-29 14:47:27 -07:00
parent 43e0bc682a
commit edeb1b1f2e
5 changed files with 135 additions and 94 deletions

View File

@@ -259,3 +259,19 @@
(dates->date-times)
(on-success)
(re-frame/dispatch))))))))
(defonce interval-handler
(let [live-intervals (atom {})]
(fn handler [{:keys [action id frequency event]}]
(condp = action
:clean (doall
(map #(handler {:action :end :id %1}) (keys @live-intervals)))
:start (swap! live-intervals assoc id (js/setInterval #(re-frame/dispatch event) frequency))
:end (do (js/clearInterval (get @live-intervals id))
(swap! live-intervals dissoc id))))))
(interval-handler {:action :clean})
(re-frame.core/reg-fx ;; the re-frame API for registering effect handlers
:interval ;; the effect id
interval-handler)