consul/ui-v2/app/services/lazy-proxy.js
John Cowen cb0c5309c9 UI: Add EventSource ready for implementing blocking queries (#5070)
- 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)
2019-05-01 18:22:06 +00:00

28 lines
762 B
JavaScript

import Service from '@ember/service';
import { get } from '@ember/object';
export default Service.extend({
shouldProxy: function(content, method) {
return false;
},
init: function() {
this._super(...arguments);
const content = get(this, 'content');
for (let prop in content) {
if (typeof content[prop] === 'function') {
if (this.shouldProxy(content, prop)) {
this[prop] = function() {
return this.execute(content, prop).then(method => {
return method.apply(this, arguments);
});
};
} else if (typeof this[prop] !== 'function') {
this[prop] = function() {
return content[prop](...arguments);
};
}
}
}
},
});