Clojurescript re-mount module, that synchronises UI time with the blockchain time.
Add [district0x/district-ui-web3-sync-now "1.0.3-1"]
into your project.clj.
Include [district.ui.web3-sync-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]
[district.ui.web3]
[district.ui.web3-sync-now]
[district.ui.logging]))
(-> (mount/with-args {:logging {:level :info}
:web3 {:url "http://127.0.0.1:8549"}})
(mount/start))
After the :start
lifecycle method gets called this module waits for the :district.ui.web3.events/web3-created
event and sets :district.ui.now.subs/now
time to the last block time on the blockchain.
Set the logging level to get notified of errors and/or successfull events.
re-frame events provided by this module:
::increment-now
Event to increment now time in a re-frame db and the (testrpc) blockchain time by a number of seconds.
(ns my-district.core
(:require [district.ui.web3-sync-now.events :as sync-now-events]
[re-frame.core :as re-frame]))
(re-frame/dispatch [::sync-now-events/increment-now 300])
Errors and successfully handled events will be logged to the JS console.
::block-number
This is an utility event called by the :start
lifecycle method of the module.
It wraps the re-frame-web3-fx web3/call
effect and chains the returned last block number to the ::get-block
event.
In a typical application you will never need to call this event yourself.
::get-block
This is an utility event which wraps the re-frame-web3-fx web3/call
effect and chains the returned last block object to the ::set-now
.
In a typical application you will never need to call this event yourself.
::set-now
This is an utility event which sets the :district.ui.now.subs/now
time from the last block time.
Upon success it will log to the JS console.
In a typical application you will never need to call this event yourself.
Run test suite:
lein deps
# To run tests and rerun on changes
lein doo chrome tests
Install into local repo:
lein install
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close