@motorcycle/html
v1.1.3
Published
Motorcycle.js HTML Driver
Downloads
14
Readme
Motorcycle HTML Driver
This is the standard HTML driver for Motorcycle built using snabbdom-to-html.
Installing
$ npm install @motorcycle/html
Want to Contribute?
If you found an issue or want to contribute code, please read the contributing guidelines.
Example Usage
import {run} from '@motorcycle/core'
import {h2} from '@motorcycle/dom'
import htmlDriver from '@motorcycle/html'
function app(sources) {
...
return {
HTML: most.just(h2('Hello, world!'))
}
}
const {sources} = run(app, {
HTML: htmlDriver,
})
sources.HTML.select(':root').observable.observe(html => {...})
API
htmlDriver(source$)
htmlDriver is a function which takes a stream of Snabbdom virtual nodes and returns a stream of HTML strings.
Arguments
source$ :: most.Stream - A stream of Snabbdom virtual nodes.
Returns
(Object): An object with a single method select()
.
select() :: Function - A function which return as an object containing observable
and events()
.
observable :: most.Stream - A stream of HTML strings.
events() :: Function - A function which returns an empty stream for compatibility with the DOM driver API.