0.2.1 • Published 7 years ago
flimflam-render v0.2.1
flimflam-render
Render a Flimflam UI component onto the page (and keep rendering/patching it on every stream update).
This module is included in the core flimflam
package, and you can require it require('flimflam/render')
.
render(view, state, container)
This function is all you need to render your top-level UI component to the page. It only needs to be called once for a whole one-page app using the top-most view and state.
view
: the top-level view function that takes the state as a parameter and returns a vnode treestate
: an object containing values, flyd streams, and nested objects for use in the viewcontainer
: a regular DOM Node that you want to replace with the markup generated by your view function
Usage
const render = require('flimflam/render')
// import your app's parent component and view function...
const component = require('./my-component')
const view = component.view
const state = component.init()
const container = document.body
render(view, state, container)
development
Tests use tape and tape-run, and can be executed with: npm run test
The main index.js file is plain ES5, while the test file uses browserify with es2040.