diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2017-04-14 16:01:25 -0500 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2017-04-14 16:01:25 -0500 |
commit | f1e420f6865c57e69bb34fa6f55264d19640e11a (patch) | |
tree | 7b5b4f9e9b395f722a626ac5eac4270e5d51d100 /app/assets/javascripts/subbable_resource.js | |
parent | 29e0b635dcf7cae982857378e93917d29dc61506 (diff) | |
download | gitlab-ce-refactor-time-tracking.tar.gz |
Refactor time trackingrefactor-time-tracking
Diffstat (limited to 'app/assets/javascripts/subbable_resource.js')
-rw-r--r-- | app/assets/javascripts/subbable_resource.js | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/app/assets/javascripts/subbable_resource.js b/app/assets/javascripts/subbable_resource.js deleted file mode 100644 index d8191605128..00000000000 --- a/app/assets/javascripts/subbable_resource.js +++ /dev/null @@ -1,51 +0,0 @@ -(() => { -/* -* SubbableResource can be extended to provide a pubsub-style service for one-off REST -* calls. Subscribe by passing a callback or render method you will use to handle responses. - * -* */ - - class SubbableResource { - constructor(resourcePath) { - this.endpoint = resourcePath; - - // TODO: Switch to axios.create - this.resource = $.ajax; - this.subscribers = []; - } - - subscribe(callback) { - this.subscribers.push(callback); - } - - publish(newResponse) { - const responseCopy = _.extend({}, newResponse); - this.subscribers.forEach((fn) => { - fn(responseCopy); - }); - return newResponse; - } - - get(payload) { - return this.resource(payload) - .then(data => this.publish(data)); - } - - post(payload) { - return this.resource(payload) - .then(data => this.publish(data)); - } - - put(payload) { - return this.resource(payload) - .then(data => this.publish(data)); - } - - delete(payload) { - return this.resource(payload) - .then(data => this.publish(data)); - } - } - - gl.SubbableResource = SubbableResource; -})(window.gl || (window.gl = {})); |