diff --git a/source/Ox.UI/js/Core/API.js b/source/Ox.UI/js/Core/API.js index 943a15cf..caa7ccf2 100644 --- a/source/Ox.UI/js/Core/API.js +++ b/source/Ox.UI/js/Core/API.js @@ -1,11 +1,23 @@ 'use strict'; /*@ -Ox.API bind remote api to object -options Options object - timeout request timeout - url request url -callback called once api discover is done +Ox.API Remote API controller + options Options object + timeout request timeout + url request url + callback called once api discover is done + ([options, ] callback) -> API controller + api Remote API discovery (calls the API's `api` method) + (callback) -> Request id + callback Callback functions + .* Remote API method call + ([data, [age, ]]callback) -> Request id + data Request data + age Max-age in ms (0: not from cache, -1: from cache) + callback Callback function + cancel Cancels a request + (id) -> undefined + id Request id @*/ Ox.API = function(options, callback) { @@ -20,7 +32,7 @@ Ox.API = function(options, callback) { }, that = { api: function(callback) { - Ox.Request.send({ + return Ox.Request.send({ url: self.options.url, data: {action: 'api'}, callback: callback @@ -37,12 +49,6 @@ Ox.API = function(options, callback) { url: self.options.url }); - /*@ - api bakcend API - [action] all api requests available on backend - cancel cancel a request - options get or set options - @*/ that.api(function(result) { Ox.forEach(result.data.actions, function(val, key) { that[key] = function(/*data, age, callback*/) { @@ -65,10 +71,12 @@ Ox.API = function(options, callback) { data: JSON.stringify(data) }, url: self.options.url - }, !val.cache ? {age: 0}: {})); + }, !val.cache ? {age: 0} : {})); }; }); callback && callback(); }); + return that; + };