client/src/index.js
function remoteRequest(moduleName, methodName, argsArr) {
  // TODO: Handle moduleName properly
  // TODO: Better ID generation
  const id = Math.floor(Math.random() * 10000000);
  const serializedRequest = serializer.request(id, methodName, argsArr);

  return sendRequest(serializedRequest).then((res) => {
    const response = serializer.deserialize(res.text);
    if (response.type === 'success') {
      return response.payload.result;
    } else if (response.type === 'error') {
      throw response.payload.error;
    } else {
      // TODO: Better error handling
      throw response;
    }
  });
}
function remoteRequest(moduleName, methodName, argsArr) {
  // TODO: Handle moduleName properly
  // TODO: Better ID generation
  const id = Math.floor(Math.random() * 10000000);
  const serializedRequest = serializer.request(id, methodName, argsArr);

  return sendRequest(serializedRequest).then((res) => {
    const response = serializer.deserialize(res.text);
    if (response.type === 'success') {
      return response.payload.result;
    } else if (response.type === 'error') {
      throw response.payload.error;
    } else {
      // TODO: Better error handling
      throw response;
    }
  });
}
function remoteRequest ( moduleName , methodName , argsArr ) { // TODO: Handle moduleName properly // TODO: Better ID generation const id = Math . floor ( Math . random ( ) * 10000000 ) ; const serializedRequest = serializer . request ( id , methodName , argsArr ) ; return sendRequest ( serializedRequest ) . then ( ( res ) => { const response = serializer . deserialize ( res . text ) ; if ( response . type === 'success' ) { return response . payload . result ; } else if ( response . type === 'error' ) { throw response . payload . error ; } else { // TODO: Better error handling throw response ; } } ) ; }
Executes a RPC and returns a Promise resolving to the returned value or
rejecting on a client or remote exception.
@param  {String} moduleName  Full module path to resolve on remote
@param  {String} methodName  Method name to invoke on remote
@param  {Array} argsArr      Array of arguments to invoke the remote
method with
@return {Promise}            Promise resolving to the return value of the
remote function or rejecting due to
a client or remote exception
Executes a RPC and returns a Promise resolving to the returned value or rejecting on a client or remote exception .