Skip to content

Conversation

@timt-unity3d
Copy link

I'm overriding the send function to use oboe to allow streaming processing of batches as they are returned from the server. This allows me to override the base send function and decorate the standard nodeJsMultiFetchAdapter like so:

angular
  .module('shared.adapter', ['jcs.angular-http-batch'])
  .decorator('nodeJsMultiFetchAdapter', function($delegate) {

    $delegate.send = function() {
      var self = this,
        adapter = self.getAdapter(),
        httpBatchConfig = adapter.buildRequest(self.requests, self.config);

      self.sendCallback();
      httpBatchConfig.withCredentials = true;
      oboe(httpBatchConfig)
        .node('!.*', function(node, path) {

         if (self.requests[path]) {
            self.requests[path].callback(
              node.statusCode,
              node.body,
              convertHeadersToString(node.headers),
              node.statusText
            );
          }
        });
    };

    return $delegate;
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant