Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
});
});
}
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();
});
}