-
Notifications
You must be signed in to change notification settings - Fork 1
/
polling.cljs
37 lines (36 loc) · 1.3 KB
/
polling.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(ns cockpit.polling
(:require
[cockpit.clock :as clock]
[cockpit.config :as config]
[cockpit.stocks :as stocks]
[cockpit.transit :as transit]
[cockpit.webcam :as webcam]
[cockpit.weather :as weather]))
(def rules
(vec
(concat
[{:interval 1
:event [::clock/timer]
:dispatch-event-on-start? true}
{:interval 1
:event [::webcam/update-image]
:dispatch-event-on-start? true}
{:interval 900 ; 15 minutes
:event [::weather/fetch-weather]
:dispatch-event-on-start? true}]
(map (fn [sym]
{:interval 900 ; 15 minutes
:event [::stocks/fetch-stocks sym]
:dispatch-event-on-start? true})
config/stocks)
(map (fn [event]
{:interval 30
:event event
:dispatch-event-on-start? true})
(transit/generate-stop-time-events
config/transit-stop-whitelist))
(map (fn [event]
{:interval 604800 ; 1 week
:event event
:dispatch-event-on-start? true})
(transit/generate-stop-events config/transit-stop-whitelist)))))