packages/grpc-native-core/src/client_interceptors.js
function _getStreamReadCallback(emitter, call, get_listener, deserialize) {
  return function (err, response) {
    if (err) {
      // Something has gone wrong. Stop reading and wait for status
      emitter.finished = true;
      emitter._readsDone();
      return;
    }
    var data = response.read;
    var deserialized;
    try {
      deserialized = deserialize(data);
    } catch (e) {
      emitter._readsDone({
        code: constants.status.INTERNAL,
        details: 'Failed to parse server response'
      });
      return;
    }
    if (data === null) {
      emitter._readsDone();
      return;
    }
    var listener = get_listener();
    var context = {
      call: call,
      listener: listener
    };
    listener.recvMessageWithContext(context, deserialized);
  };
}
function _getStreamReadCallback(emitter, call, get_listener, deserialize) {
  return function (err, response) {
    if (err) {
      // Something has gone wrong. Stop reading and wait for status
      emitter.finished = true;
      emitter._readsDone();
      return;
    }
    var data = response.read;
    var deserialized;
    try {
      deserialized = deserialize(data);
    } catch (e) {
      emitter._readsDone({
        code: constants.status.INTERNAL,
        details: 'Failed to parse server response'
      });
      return;
    }
    if (data === null) {
      emitter._readsDone();
      return;
    }
    var listener = get_listener();
    var context = {
      call: call,
      listener: listener
    };
    listener.recvMessageWithContext(context, deserialized);
  };
}
function _getStreamReadCallback ( emitter , call , get_listener , deserialize ) { return function ( err , response ) { if ( err ) { // Something has gone wrong. Stop reading and wait for status emitter . finished = true ; emitter . _readsDone ( ) ; return ; } var data = response . read ; var deserialized ; try { deserialized = deserialize ( data ) ; } catch ( e ) { emitter . _readsDone ( { code : constants . status . INTERNAL , details : 'Failed to parse server response' } ) ; return ; } if ( data === null ) { emitter . _readsDone ( ) ; return ; } var listener = get_listener ( ) ; var context = { call : call , listener : listener } ; listener . recvMessageWithContext ( context , deserialized ) ; } ; }
Produces a callback triggered by streaming response messages.
@private
@param {EventEmitter} emitter
@param {grpc.internal~Call} call
@param {function} get_listener Returns a grpc~Listener.
@param {grpc~deserialize} deserialize
@return {Function}
Produces a callback triggered by streaming response messages .