1.0.0-alpha.6 • Published 7 years ago
streaming-http-request v1.0.0-alpha.6
streaming-http-request
Make HTTP requests for streams of data from the browser
Usage
import StreamingHttpRequest from 'streaming-http-request';
new StreamingHttpRequest(url);
Each instance of StreamingHttpRequest
is an object similar to Node.js EventEmitter
that emits the following events:
data
- emitted with an object for each parsed JSON message streamed from the responseerror
- emitted each time the underlyingXMLHttpRequest
object orJSON.parse
function call throws an error
A StreamingHttpRequest
instance immediately begins emitting data after the first data
event listener is added, and it stops emitting data after the last listener is removed.
Example usage with recompose.lifecycle:
lifecycle({
componentWillMount() {
this.request = new StreamingHttpRequest(url);
this.request.addListener('data', this.props.handleData);
this.request.addListener('error', this.props.handleError);
},
componentWillUnmount() {
this.request.removeListener('data', this.props.handleData);
this.request.removeListener('error', this.props.handleError);
},
}),
1.0.0-alpha.6
7 years ago
1.0.0-alpha.5
7 years ago
1.0.0-alpha.4
7 years ago
1.0.0-alpha.3
7 years ago
1.0.0-alpha.2
7 years ago
1.0.0-alpha.1
7 years ago