How to use the grpc-web.AbstractClientBase.MethodInfo function in grpc-web

To help you get started, we’ve selected a few grpc-web examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngx-grpc / core / projects / core / src / lib / grpc-client.ts View on Github external
return new Observable(obs => {
      this.client.rpcCall(
        this.settings.host + path,
        req,
        metadata || {},
        new AbstractClientBase.MethodInfo(
          resclss,
          (request: REQ) => reqclss.toBinary(request),
          resclss.fromBinary
        ),
        (err: Error, response: RES) => {
          if (err) {
            obs.error(err);
          } else {
            obs.next(response);
          }

          obs.complete();
        });
    });
  }
github ngx-grpc / core / projects / core / src / lib / grpc-client.ts View on Github external
return new Observable(obs => {
      const xhrStream = this.client.serverStreaming(
        this.settings.host + path,
        req,
        metadata || {},
        new AbstractClientBase.MethodInfo(resclss, (request: REQ) => reqclss.toBinary(request), resclss.fromBinary)
      );

      xhrStream.on('status', status => obs.next(status));
      xhrStream.on('data', response => obs.next(response));
      xhrStream.on('end', () => obs.complete());
      xhrStream.on('error', error => obs.error(error));

      return () => xhrStream.cancel();
    });
  }