https://github.com/serapath/dom-stream
stream dom elements
https://github.com/serapath/dom-stream
Last synced: about 1 year ago
JSON representation
stream dom elements
- Host: GitHub
- URL: https://github.com/serapath/dom-stream
- Owner: serapath
- License: mit
- Created: 2016-11-21T11:04:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-09T00:10:12.000Z (about 9 years ago)
- Last Synced: 2025-03-16T00:09:53.684Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/dom-stream
- Size: 45.9 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dom-stream
stream a dom element and it's updates into a dom element container
# usage
`npm install dom-stream`
```js
var bel = require('bel')
var domstream = require('dom-stream')
function demoComponent (opts) {
opts || (opts = {})
opts.placeholder = bel`
...` // optional
var el$ = domstream(opts) // el$ is a read stream AND dom element
el$.on('data', function (el) { console.log('dom element update', el) })
setTimeout(next, 500, 0) // update dom element el$
return el$
function next (i) { el$.push(render(i)); setTimeout(next, 500, i++) }
function render () { return bel`update ${i}` }
}
var el$ = demoComponent()
document.body.appendChild(el$)
```
#### demo https://serapath.github.io/dom-stream/