mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-14 18:54:52 +00:00
18 lines
623 B
Clojure
18 lines
623 B
Clojure
(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]
|
|
[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))))
|