event-source-any-where
v1.0.5
Published
A polyfill for http://www.w3.org/TR/eventsource/
Downloads
17
Maintainers
Readme
#React Native Event Source Base On: https://github.com/eohland/EventSource
#install for node,react-native: npm install event-source-any-where --save #install for HTML:
Using On React Navtive, NodeJS (not require in html5)
require('event-source-any-where'); // for overwrite EventSource
Using EventSource
let _consumer = new EventSourceEx(YourUrl);
// add event
_consumer.addEventListener(YourKey, Callback);
// remove event
_consumer.removeEventListener(YourKey, Callback);
// close connection
_consumer.close();
#Example:
require('event-source-any-where');
this._consumer = new EventSourceEx(CONFIG.urlAuth + CONFIG.serviceConsumer);
this._consumer.addEventListener("message", this.onReceiveMessage);
this._consumer.addEventListener("error", this.onConnectError);