virtual-dom-stream
v1.0.1
Published
Stream a virtual-dom tree as HTML
Downloads
4
Maintainers
Readme
virtual-dom-stream
Stream a virtual-dom tree as HTML. Useful to render virtual-dom
/ mercury
nodes on the server.
Installation
$ npm install virtual-dom-stream
Usage
const vdom = require('virtual-dom-stream')
const h = require('virtual-dom/h')
const hs = require('hyperstream')
const bankai = require('bankai')
const http = require('http')
// render a vdom tree to html and append it to body in a stream
// and return it as a server response
const html = bankai.html()
http.createServer(function (req, res) {
html(req, res)
.pipe(hs({ body: { _appendHtml: vdom(createTree()) } }))
.pipe(res)
}).listen()
function createTree () {
return h('.greeting', [
'hello world'
])
}
API
readableStream = virtualDomStream(tree)
Render a virtual-dom
tree of h
nodes to a readable stream.