src/js/lib/common/helper.js
/**
 * create new listener if function listener is null
 *
 * @param {RTRemoteProtocol}protocol the protocol that send call request
 * @param {object} rtFunction the old rt remote function
 * @return {object} the new rt function
 */
create new listener if function listener is null
@param {RTRemoteProtocol}protocol the protocol that send call request
@param {object} rtFunction the old rt remote function
@return {object} the new rt function
create new listener if function listener is null @param { RTRemoteProtocol } protocol the protocol that send call request @param { object } rtFunction the old rt remote function @return { object } the new rt function
function updateListenerForRTFuction(protocol, rtFunction) {
  if (rtFunction && rtFunction[RTConst.VALUE] && rtFunction[RTConst.VALUE][RTConst.VALUE]) {
    return rtFunction;
  }
  const newRtFunction = {};
  const rtValue = {};
  newRtFunction[RTConst.VALUE] = (rtValueList) => {
    const args = rtValueList || [];
    return protocol.sendCallByName(
      rtFunction[RTConst.VALUE][RTConst.OBJECT_ID_KEY],
      rtFunction[RTConst.VALUE][RTConst.FUNCTION_KEY], ...args,
    );
  };
  newRtFunction[RTConst.FUNCTION_KEY] = rtFunction[RTConst.VALUE][RTConst.FUNCTION_KEY];
  newRtFunction[RTConst.OBJECT_ID_KEY] = rtFunction[RTConst.VALUE][RTConst.OBJECT_ID_KEY];
  rtValue[RTConst.VALUE] = newRtFunction;
  rtValue[RTConst.TYPE] = RTValueType.FUNCTION;
  RTEnvironment.getRtFunctionMap()[newRtFunction[RTConst.FUNCTION_KEY]] = newRtFunction[RTConst.VALUE];
  return rtValue;
}
function updateListenerForRTFuction ( protocol , rtFunction ) { if ( rtFunction && rtFunction [ RTConst . VALUE ] && rtFunction [ RTConst . VALUE ] [ RTConst . VALUE ] ) { return rtFunction ; } const newRtFunction = { } ; const rtValue = { } ; newRtFunction [ RTConst . VALUE ] = ( rtValueList ) => { const args = rtValueList || [ ] ; return protocol . sendCallByName ( rtFunction [ RTConst . VALUE ] [ RTConst . OBJECT_ID_KEY ] , rtFunction [ RTConst . VALUE ] [ RTConst . FUNCTION_KEY ] , ... args , ) ; } ; newRtFunction [ RTConst . FUNCTION_KEY ] = rtFunction [ RTConst . VALUE ] [ RTConst . FUNCTION_KEY ] ; newRtFunction [ RTConst . OBJECT_ID_KEY ] = rtFunction [ RTConst . VALUE ] [ RTConst . OBJECT_ID_KEY ] ; rtValue [ RTConst . VALUE ] = newRtFunction ; rtValue [ RTConst . TYPE ] = RTValueType . FUNCTION ; RTEnvironment . getRtFunctionMap ( ) [ newRtFunction [ RTConst . FUNCTION_KEY ] ] = newRtFunction [ RTConst . VALUE ] ; return rtValue ; }
create new listener if function listener is null
 @param {RTRemoteProtocol}protocol the protocol that send call request
 @param {object} rtFunction the old rt remote function
 @return {object} the new rt function
create new listener if function listener is null @param { RTRemoteProtocol } protocol the protocol that send call request @param { object } rtFunction the old rt remote function @return { object } the new rt function