package
Attach a virtual dom element to the DOM and sync changes
npm install virtual-attachGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Attach a virtual dom element to the DOM and sync changes
$ npm install --save virtual-attachvar attach = require('virtual-attach')
var Struct = require('observ-struct')
var h = require('virtual-dom/h')
function Component () {
return Struct({
foo: 'bar'
})
}
Component.render = function render (state) {
return h('div', state.foo)
}
// dom element whose contents match the vtree returned from component.render,
// which will be updated when state changes
var element = attach(Component(), Component.render)var element = attach(state, render)Returns a DOM element matching the vtree returned from render when called with state.
An observable state
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.
MIT © Andrew Joslin
Estimated unpacked size across 18 packages.
140.7 kB
Includes dependencies.