mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 05:45:46 +00:00
cb0c5309c9
- Maintain http headers as JSON-API meta for all API requests (#4946) - Add EventSource ready for implementing blocking queries - EventSource project implementation to enable blocking queries for service and node listings (#5267) - Add setting to enable/disable blocking queries (#5352)
24 lines
600 B
JavaScript
24 lines
600 B
JavaScript
/**
|
|
* Wraps an EventSource so that you can `close` and `reopen`
|
|
*
|
|
* @param {Class} eventSource - EventSource class to extend from
|
|
*/
|
|
export default function(eventSource = EventSource) {
|
|
return class extends eventSource {
|
|
constructor(source, configuration) {
|
|
super(...arguments);
|
|
this.configuration = configuration;
|
|
}
|
|
reopen() {
|
|
switch (this.readyState) {
|
|
case 3: // CLOSING
|
|
this.readyState = 1;
|
|
break;
|
|
case 2: // CLOSED
|
|
eventSource.apply(this, [this.source, this.configuration]);
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
}
|