clojurescript configuration variables

823 views
Skip to first unread message

Petunio Waterpillow

unread,
Apr 7, 2015, 4:44:29 PM4/7/15
to clojur...@googlegroups.com
i'm developing a clojurescript webapp
it fetches via jsonp any rss and draws it on a html page
given this, it should work with any source so there are some variables i would like were configurable (yes, i mean the rss url, for example)

having this variables in a config file would be very handy when cloning the app
i've seen several libraries like https://github.com/james-henderson/nomad and i guess they would do the job, but they're more oriented to system configuration and environments

i wonder if exists something more specific for my needs

Sebastian Bensusan

unread,
Apr 8, 2015, 10:17:34 AM4/8/15
to clojur...@googlegroups.com
Hi,

I use https://github.com/weavejester/environ for configuration. To call it from ClojureScript I usually wrap it in a macro like this:

app/env.clj

(ns app.env
(:require [environ.core :refer [env]]))

(defmacro cljs-env [kw]
(env kw))

put it in on project.clj

:env {:rss-uri "i-dont-know-how-rss-uri-look-like"}

and then call it from ClojureScript like this:

app/view.cljs

(ns app.view
(:require-macros [app.env :as env :refer [cljs-env])

(cljs-env :rss-uri)

Note that the keyword :rss-uri needs to be available at compile time, since that's when the code `(env kw)` will run.

Hope this helps

Petunio Waterpillow

unread,
Apr 13, 2015, 4:59:03 AM4/13/15
to clojur...@googlegroups.com
thank you, sir
it works
Reply all
Reply to author
Forward
0 new messages