Clide
Clide is a simple render loop for snabbdom.
Installation
npm install clide
Usage
Example: A Simple Counter
counter { const count = 0 } = return }
Example: Two Counters
app { return } { const count = 0 } = return }
Example: Many Counters
app { const counters = } = return } { const count = 0 } = return }
API
init(modules)
The init
function takes an optional array of extra snabbdom modules to load
and returns the render
function. See the snabbdom init
docs for more details about
loading extra snabbdom modules.
render(view, options)
The render
function is returned by init
. This function should be called with a
view
function, and optionally an options object. The options object
may contain the following properties:
Property | Default | Description |
---|---|---|
state | {} |
The initial state that should be returned by lens() . |
root | document.body |
The DOM node to attach the view function to. |
view(lens)
The view
function is written by the developer, and should expect one argument:
a lens
from stateful-lens. This
function must return a snabbdom virtual
dom node. Updating the lens
in this function will trigger a re-render. See the
stateful-lens docs for more
information.