18 lines
623 B
Plaintext
Raw Normal View History

(ns status-im.network.handlers
(:require [re-frame.core :refer [dispatch debug enrich after]]
[status-im.utils.handlers :refer [register-handler]]
[status-im.utils.handlers :as u]
2016-12-27 15:46:06 +02:00
[status-im.network.net-info :as ni]))
(register-handler :listen-to-network-status!
(u/side-effect!
(fn []
(let [handler #(dispatch [:update-network-status %])]
(ni/init handler)
(ni/add-listener handler)))))
(register-handler :update-network-status
(fn [db [_ is-connected?]]
(let [status (if is-connected? :online :offline)]
(assoc db :network-status status))))