packages/grpc-native-core/src/client_interceptors.js
function _getUnaryListener(method_definition, emitter, callback) {
  var resultMessage;
  return {
    onReceiveMetadata: function (metadata) {
      emitter.emit('metadata', metadata);
    },
    onReceiveMessage: function (message) {
      resultMessage = message;
    },
    onReceiveStatus: function (status) {
      if (status.code !== constants.status.OK) {
        var error = common.createStatusError(status);
        callback(error);
      } else {
        callback(null, resultMessage);
      }
      emitter.emit('status', status);
    }
  };
}
function _getUnaryListener(method_definition, emitter, callback) {
  var resultMessage;
  return {
    onReceiveMetadata: function (metadata) {
      emitter.emit('metadata', metadata);
    },
    onReceiveMessage: function (message) {
      resultMessage = message;
    },
    onReceiveStatus: function (status) {
      if (status.code !== constants.status.OK) {
        var error = common.createStatusError(status);
        callback(error);
      } else {
        callback(null, resultMessage);
      }
      emitter.emit('status', status);
    }
  };
}
function _getUnaryListener ( method_definition , emitter , callback ) { var resultMessage ; return { onReceiveMetadata : function ( metadata ) { emitter . emit ( 'metadata' , metadata ) ; } , onReceiveMessage : function ( message ) { resultMessage = message ; } , onReceiveStatus : function ( status ) { if ( status . code !== constants . status . OK ) { var error = common . createStatusError ( status ) ; callback ( error ) ; } else { callback ( null , resultMessage ) ; } emitter . emit ( 'status' , status ) ; } } ; }
Produces a listener for responding to callers of unary RPCs.
@private
@param {grpc~MethodDefinition} method_definition
@param {EventEmitter} emitter
@param {function} callback
@return {grpc~Listener}
Produces a listener for responding to callers of unary RPCs .