https://github.com/nichoth/react-pull-stream
Duplex stream connected to a react component
https://github.com/nichoth/react-pull-stream
Last synced: about 1 year ago
JSON representation
Duplex stream connected to a react component
- Host: GitHub
- URL: https://github.com/nichoth/react-pull-stream
- Owner: nichoth
- Created: 2016-10-23T20:22:24.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-10-09T22:54:22.000Z (almost 9 years ago)
- Last Synced: 2025-05-14T11:57:18.646Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# react pull stream
**This is deprecated.** See http://npm.im/@invintus/react-pull-stream
Create a duplex stream from a react component.
## install
$ npm install react-pull-stream
## example
```js
var React = require('react')
var h = React.createElement
var reactDom = require('react-dom')
var S = require('pull-stream')
var toStream = require('../')
function MyView (props) {
function click (n) {
props.push(n)
}
return h('div', {
className: 'app'
}, [
h('h1', { key: 'h' }, props.count),
h('button', { key: 1, onClick: click.bind(null, 1) }, '1'),
h('button', { key: 2, onClick: click.bind(null, 2) }, '2'),
h('button', { key: 3, onClick: click.bind(null, 3) }, '3'),
])
}
MyView.defaultProps = { count: 0 }
// duplex stream
var stream = toStream(MyView, function onEnd (err) {
console.log('its over')
})
var el = document.createElement('div')
document.body.appendChild(el)
reactDom.render(React.createElement(stream.view), el)
S(
stream,
S.map( n => ({ count: n }) ),
stream
)
S(
// you can have mulitple subscripbers
stream.source.listen(),
S.log()
)
stream.abort() // end things
```