nav tabs on admin dashboard
This commit is contained in:
+43
-25
@@ -1,34 +1,39 @@
|
||||
# EventSource [](http://travis-ci.org/aslakhellesoy/eventsource-node) [](https://david-dm.org/aslakhellesoy/eventsource-node) [](https://bitdeli.com/free "Bitdeli Badge")
|
||||
# EventSource [](http://browsenpm.org/package/eventsource)[](https://travis-ci.org/EventSource/eventsource)[](http://npm-stat.com/charts.html?package=eventsource&from=2015-09-01)[](https://david-dm.org/EventSource/eventsource)
|
||||
|
||||
This library is a pure JavaScript implementation of the [EventSource](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events) client. The API aims to be W3C compatible.
|
||||
|
||||
[](https://nodei.co/npm/eventsource/)
|
||||
[](https://nodei.co/npm/eventsource/)
|
||||
|
||||
This library implements the [EventSource](http://dev.w3.org/html5/eventsource/) client for Node.js. The API aims to be W3C compatible.
|
||||
You can use it with Node.js or as a browser polyfill for
|
||||
[browsers that don't have native `EventSource` support](http://caniuse.com/#feat=eventsource).
|
||||
|
||||
## Install
|
||||
|
||||
npm install eventsource
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var EventSource = require('eventsource');
|
||||
|
||||
var es = new EventSource('http://demo-eventsource.rhcloud.com/');
|
||||
es.onmessage = function(e) {
|
||||
console.log(e.data);
|
||||
};
|
||||
es.onerror = function() {
|
||||
console.log('ERROR!');
|
||||
};
|
||||
```
|
||||
|
||||
See the [spec](http://dev.w3.org/html5/eventsource/) for API docs.
|
||||
|
||||
## Example
|
||||
|
||||
See https://github.com/einaros/sse-example
|
||||
npm install
|
||||
node ./example/sse-server.js
|
||||
node ./example/sse-client.js # Node.js client
|
||||
open http://localhost:8080 # Browser client - both native and polyfill
|
||||
curl http://localhost:8080/sse # Enjoy the simplicity of SSE
|
||||
|
||||
## Browser Polyfill
|
||||
|
||||
Just add `example/eventsource-polyfill.js` file to your web page:
|
||||
|
||||
```html
|
||||
<script src=/eventsource-polyfill.js></script>
|
||||
```
|
||||
|
||||
Now you will have two global constructors:
|
||||
|
||||
```javascript
|
||||
window.EventSourcePolyfill
|
||||
window.EventSource // Unchanged if browser has defined it. Otherwise, same as window.EventSourcePolyfill
|
||||
```
|
||||
|
||||
If you're using [webpack](https://webpack.github.io/) or [browserify](http://browserify.org/)
|
||||
you can of course build your own. (The `example/eventsource-polyfill.js` is built with webpack).
|
||||
|
||||
## Extensions to the W3C API
|
||||
|
||||
@@ -46,11 +51,11 @@ var es = new EventSource(url, eventSourceInitDict);
|
||||
|
||||
### Allow unauthorized HTTPS requests
|
||||
|
||||
By default, https requests that cannot be authorized will cause connection to fail and an exception
|
||||
to be emitted. You can override this behaviour:
|
||||
By default, https requests that cannot be authorized will cause the connection to fail and an exception
|
||||
to be emitted. You can override this behaviour, along with other https options:
|
||||
|
||||
```javascript
|
||||
var eventSourceInitDict = {rejectUnauthorized: false};
|
||||
var eventSourceInitDict = {https: {rejectUnauthorized: false}};
|
||||
var es = new EventSource(url, eventSourceInitDict);
|
||||
```
|
||||
|
||||
@@ -69,3 +74,16 @@ es.onerror = function (err) {
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### HTTP/HTTPS proxy
|
||||
|
||||
You can define a `proxy` option for the HTTP request to be used. This is typically useful if you are behind a corporate firewall.
|
||||
|
||||
```javascript
|
||||
var es = new EventSource(url, {proxy: 'http://your.proxy.com'});
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT-licensed. See LICENSE
|
||||
|
||||
Reference in New Issue
Block a user