dataRequest

Invoke service requests on Web Worker

Make data requests using events, but wrapped in Promise interface. These requests get routed to the web worker thread where one of the service interfaces will handle the AJAX request and process the response.

The service name maps to a module defined in data/web-worker/services/*, and the service method is the method to invoke in that modules exported object.

See the documented Services in the navigation menu on the left.

To create custom services in plugins refer to the Web Plugin Tutorial.

Source:
Example
// Invoke the "me" function in "data/web-worker/services/user.js" module
dataRequest('user', 'me')
 .then(function(user) {
     // The current logged in user info
 }).catch(function(err) {
   // handle error
 }

Methods

(static) dataRequest(service, method, …argsopt) → {Promise}

Source:

Make a data request

Parameters:
Name Type Attributes Description
service string

The name of service

method string

The method to invoke in service

args object <optional>
<repeatable>

arguments to pass to service

Returns:

The service request promise

Type
Promise