This release contains backwards-incompatible changes in the both the API
and philosophy.
The primary change is that the imperative `unify!` function has been
removed in favor of a `unify` datatype that represents the same idea:
"these children should match up with this template function run across
these data".
Changing from a procedure call to a value buys composability; you can now,
e.g., build static elements at the same time as mapping some dataset to DOM
elements:
```clojure
(bind! "#barchart"
[:div#barchart
[:h2 "Rad barchart!"]
[:div.bars
(unify {"A" 1, "B" 2, "C" 4, "D" 3}
(fn [[label val]]
[:div.bar
[:div.bar-fill {:style {:width (x-scale val)}}]
[:span.label label]]))]])
```
This new `bind!` macro also takes into account mutable state: any atoms
dereferenced within the body (or indirectly via a function called in the
body) are noted, and watchers added so that when any of those atoms change
state the body will be re-run and the DOM automatically updated.
The `bind!` macro itself returns a `computed-observable`, which implements
IWatchable and an IDisposable protocol (so you can remove watchers from the
dereferenced atoms).
We've found that this `bind!` macro makes C2 suitable for general DOM
manipulation and clientside application development.
For a full sample application built using this "data-driven-view" approach,
see this C2-implementation of TodoMVC:
https://github.com/lynaghk/c2-demos/tree/master/todoMVC
Since fast Hiccup rendering and state-manipulation macros aren't exactly
data visualization, they've been split out into two separate libraries.
Hiccup rendering and DOM walking/merging code is now in Singult:
https://github.com/lynaghk/singult
which is actually a CoffeeScript library (for pure speed).
There are ClojureScript bindings, and it is fully compatible with Closure
advanced mode compilation.
The JavaScript deps and externs you need will automatically get picked up
by latest (0.2.1) lein cljsbuild, so you can just pull in via `project.clj`
as usual.
The computed-observables macros are in Reflex:
https://github.com/lynaghk/reflex
which detects dereferenced atoms within the macro body.
This is useful for adding watches to multiple atoms.
Personally, I can't wait to depreciate the hell out of this one as soon as
we get a nice reactive streams framework for cljs = )
Finally, I've created a C2 mailing list here:
https://groups.google.com/forum/#!forum/c2-cljs
for questions about data visualization and app development in
Clojure(Script).
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en