Clojurescript re-mount module, that loads config from a server.
Add [district0x/district-ui-server-config "1.0.0"] into your project.clj
Include [district.ui.server-config] 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 server-config mount module.
You can pass following args to initiate this module:
:default Default config before loading:url Url to load config from. Default: /config:format Format of a server response. Options are :transit or :json. Default: :transit.:request-timeout Timeout of a request:disable-loading-at-start? Skip loading at mount start (ns my-district.core
(:require [mount.core :as mount]
[district.ui.server-config]))
(-> (mount/with-args
{:server-config {:default {:something 10}}})
(mount/start))
re-frame subscriptions provided by this module:
configReturns config. You can pass additional keys, which will do get-in into config.
(ns my-district.core
(:require [mount.core :as mount]
[district.ui.server-config.subs :as config-subs]))
(defn home-page []
(let [all-configs (subscribe [::config-subs/config])
cats-config (subscribe [::config-subs/config :cats])
small-doggos-config (subscribe [::config-subs/config :doggos :small])]
(fn []
[:div "All configs: " @all-configs]
[:div "Cats config: " @cats-config]
[:div "Small doggos config: " @small-doggos-config])))
re-frame events provided by this module:
load-config [opts]Loads config from a server. Pass same opts as to mount/with-args
set-config [new-config]Sets new config. Fired when loaded a server response. You can use this event to hook into event flow, e.g with re-frame-forward-events-fx.
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.
config [db & ks]Works the same way as sub ::config
merge-config [db new-config]Merges config and returns new re-frame db.
lein deps
# To run tests and rerun on changes
lein doo chrome tests
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |