src/httpOverWebSocket.js
/**
     * Helper function to create the deferred for the new request. We don't
     * have to do this if an existing cachable request is running - we can
     * return the promise associated with that deferred instead.
     *
     * @return {string}
     *   The UUID of the new request.
     */
Helper function to create the deferred for the new request. We don't
have to do this if an existing cachable request is running - we can
return the promise associated with that deferred instead.

@return {string}
The UUID of the new request.
Helper function to create the deferred for the new request . We don ' t have to do this if an existing cachable request is running - we can return the promise associated with that deferred instead . @return { string } The UUID of the new request .
function createDeferred() {
      var id = self.generateUuid();
      self.requests[id] = {
        deferred: self.$q.defer(),
        requestConfig: requestConfig,
      };
      var timeout = self.config.timeout;
      if (typeof requestConfig.timeout === 'number') {
        timeout = requestConfig.timeout;
      }
      if (timeout > 0) {
        self.requests[id].timeoutAfter = Date.now() + timeout;
      }
      self.requests[id].deferred.promise.success = function(fn) {
        this.then(function(response) {
          fn(response.data, response.status, response.headers, requestConfig);
        });
        return this;
      };
      self.requests[id].deferred.promise.error = function(fn) {
        this.then(null, function(response) {
          fn(response.data, response.status, response.headers, requestConfig);
        });
        return this;
      };
      return id;
    }
function createDeferred ( ) { var id = self . generateUuid ( ) ; self . requests [ id ] = { deferred : self . $q . defer ( ) , requestConfig : requestConfig , } ; var timeout = self . config . timeout ; if ( typeof requestConfig . timeout === 'number' ) { timeout = requestConfig . timeout ; } if ( timeout > 0 ) { self . requests [ id ] . timeoutAfter = Date . now ( ) + timeout ; } self . requests [ id ] . deferred . promise . success = function ( fn ) { this . then ( function ( response ) { fn ( response . data , response . status , response . headers , requestConfig ) ; } ) ; return this ; } ; self . requests [ id ] . deferred . promise . error = function ( fn ) { this . then ( null , function ( response ) { fn ( response . data , response . status , response . headers , requestConfig ) ; } ) ; return this ; } ; return id ; }
Helper function to create the deferred for the new request.
Helper function to create the deferred for the new request .
// Manage timeout. // Add success and error functions to the promise - this is a straight // clone from AngularJS code.