Clojurescript re-mount module, that provides current time. Useful when you need to display time remaining counter on the website (e.g for auctions). This module uses cljs-time.
Add [district0x/district-ui-now "1.0.2"] into your project.clj
Include [district.ui.now] in your CLJS file, where you use mount/start
Warning: district0x modules are still in early stages, therefore API can change in a future.
This namespace contains now mount module. This module has no configuration parameters.
(ns my-district.core
(:require [mount.core :as mount]
[district.ui.now]))
(-> (mount/with-args
{})
(mount/start))re-frame subscriptions provided by this module:
Returns cljs-time time of now.
Returns time remaining from now to to-time.
(ns my-district.core
(:require [mount.core :as mount]
[district.ui.now.subs :as now-subs]
[cljs-time.core :as t]))
(defn home-page []
(let [time-remaining (subscribe [::now-subs/time-remaining (t/plus (t/now) (t/seconds 50))])]
(fn []
[:div "Seconds remaining: " (:seconds @time-remaining)])))re-frame events provided by this module:
Event fired every second to update now in re-frame db.
Event to set now time in re-frame db, from which time incrementing continues.
(ns my-district.core
(:require [district.ui.now.events :as now-events]
[cljs-time.core :as t]
[re-frame.core :as re-frame]))
(re-frame/dispatch [::now-events/set-now (t/minus (t/now) (t/years 1))])Event to increment now time in re-frame db by a number of milliseconds.
(ns my-district.core
(:require [district.ui.now.events :as now-events]
[re-frame.core :as re-frame]))
(re-frame/dispatch [::now-events/increment-now 8.64e+7])DB queries provided by this module:
You should use them in your events, instead of trying to get this module's
data directly with get-in into re-frame db.
Works the same way as sub ::now.
Works the same way as sub ::time-remaining.
Associates new now and returns new re-frame db.
lein deps
# To run tests and rerun on changes
lein doo chrome tests