Skip to content

Commit 71a39fa

Browse files
committed
chain some things
1 parent e5660a1 commit 71a39fa

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/firedamp/core.clj

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
(defn tweet!
7979
[message token]
8080
(timbre/info "tweeting" message)
81-
;; XXX this might want a timeout value
8281
(md/future
8382
(tw-api/statuses-update :oauth-creds token
8483
:params {:status message})))
@@ -95,17 +94,21 @@
9594
(let [{s0 :alarm-state token :token} ctx
9695
s1 (red-alert? statuses)
9796
tweet-status (get-next-state s0 s1)]
98-
(tweet-alert! token tweet-status)
99-
(-> ctx
100-
;; why not set the state to a keyword ::bad ::good
101-
(assoc :alarm-state s1)
102-
(assoc :last-update (time/now)))))
97+
(md/chain
98+
(tweet-alert! token tweet-status)
99+
(fn [& args]
100+
(-> ctx
101+
(assoc :alarm-state s1)
102+
(assoc :last-update (time/now)))))))
103103

104104
(defn run-world!
105105
[]
106106
(md/let-flow [statuses (get-parse-statuses!)]
107-
(reset! state (alert! @state statuses))
108-
(timbre/info "current state" (:alarm-state @state))))
107+
(md/chain
108+
(alert! @state statuses)
109+
(fn [new-world]
110+
(reset! state new-world)
111+
(timbre/info "current state of the world" (:alarm-state @state))))))
109112

110113
(defn keep-checking
111114
[period]

0 commit comments

Comments
 (0)