virtual-attach
Attach a virtual dom element to the DOM and sync changes
Install
$ npm install --save virtual-attach
Usage
var attach = var Struct = var h = { return } Component { return } // dom element whose contents match the vtree returned from component.render,// which will be updated when state changesvar element =
API
var element = attach(state, render)
Returns a DOM element matching the vtree returned from render
when called with state
.
state
An observable state
render
A render function that takes in a state object and returns a virtual DOM tree. Render will be called with the observable state whenever the state changes.
attach.unlisten(element)
When called with an element returned from attach
, will stop listening for changes to state
.
License
MIT © Andrew Joslin