function genModuleGetter (instanceId) {
  var instance = instances[instanceId];
  return function (name) {
    var nativeModule = modules[name] || [];
    var output = {};
    var loop = function ( methodName ) {
      output[methodName] = function () {
        var args = [], len = arguments.length;
        while ( len-- ) args[ len ] = arguments[ len ];

        var finalArgs = args.map(function (value) {
          return normalize(value, instance)
        });
        renderer.sendTasks(instanceId + '', [{ module: name, method: methodName, args: finalArgs }], -1);
      };
    };

    for (var methodName in nativeModule) loop( methodName );
    return output
  }
}
function genModuleGetter (instanceId) {
  var instance = instances[instanceId];
  return function (name) {
    var nativeModule = modules[name] || [];
    var output = {};
    var loop = function ( methodName ) {
      output[methodName] = function () {
        var args = [], len = arguments.length;
        while ( len-- ) args[ len ] = arguments[ len ];

        var finalArgs = args.map(function (value) {
          return normalize(value, instance)
        });
        renderer.sendTasks(instanceId + '', [{ module: name, method: methodName, args: finalArgs }], -1);
      };
    };

    for (var methodName in nativeModule) loop( methodName );
    return output
  }
}
function genModuleGetter ( instanceId ) { var instance = instances [ instanceId ] ; return function ( name ) { var nativeModule = modules [ name ] || [ ] ; var output = { } ; var loop = function ( methodName ) { output [ methodName ] = function ( ) { var args = [ ] , len = arguments . length ; while ( len -- ) args [ len ] = arguments [ len ] ; var finalArgs = args . map ( function ( value ) { return normalize ( value , instance ) } ) ; renderer . sendTasks ( instanceId + '' , [ { module : name , method : methodName , args : finalArgs } ] , - 1 ) ; } ; } ; for ( var methodName in nativeModule ) loop ( methodName ) ; return output } }
Generate native module getter. Each native module has several
methods to call. And all the behaviors is instance-related. So
this getter will return a set of methods which additionally
send current instance id to native when called. Also the args
will be normalized into "safe" value. For example function arg
will be converted into a callback id.
@param  {string}  instanceId
@return {function}
Generate native module getter . Each native module has several methods to call . And all the behaviors is instance - related . So this getter will return a set of methods which additionally send current instance id to native when called . Also the args will be normalized into safe value . For example function arg will be converted into a callback id .
Generate a getter function for a module