Easy Incremental Dom rendering using ClojureScript.
Fast dom updating with a low compiled size. Since Incremental Dom is closure compiler compatible, it adds very little overhead to your clojurescript project. The TODOMVC example is 147kb after compilation, and only 35kb gzipped.
inkle's interface is strongly influenced by Reagent - all you need is a simple function which returns a hiccup-like data structure.
(ns hello-world.core
(:require [goog.dom :as dom]
[inkle.core :as inkle]))
(defn hello-world [name]
[:h1#hello-world
[:div.title "Hello " name]])
(inkle/renderer (dom/getElement "app") [hello-world "John"])
Updating is managed using atoms:
(ns counter.core
(:require [goog.dom :as dom]
[inkle.core :as inkle]))
(defn counter [name]
(let [count (inkle/iatom 0)]
(fn []
[:div
[:span "Clicked " @count " times"]
[:button {:onclick #(swap! count inc)}
"Click Me!"]])))
(inkle/renderer (dom/getElement "app") [counter])
For more examples, see the example
folder
inkle is still very early stage, and should be expected to be buggy.
Some of the key TODOs:
- Add support for incremental dom's static keys, possibly using meta data
- Improve component lifecycle handling to avoid unnecessary dom updating
- Investigate server side rendering
- Add some tests
inkle is strongly based on Reagent, including the atom concept (which they in turn borrowed from reflex).
inkle is released under the MIT licence