module.Loader Extends
The dynamic loading functionality is defined as a class. The class will be used as singleton. There is, however, a two step initialization procedure because parameters need to be passed to the goog.module.Loader instance.

Inheritance

Constructor

goog.module.Loader()

Instance Methods

Public Protected Private
getModuleUrl_(urlBasemodule) string
Creates a full URL to the compiled module code given a base URL and a module name. By default it's urlBase + '_' + module + '.js'.
Arguments:
urlBase : string
URL to the module files.
module : string
Module name.
Returns: string  The full url to the module binary.
code »
init(baseUrlopt_urlFunction)
Initializes the Loader to be fully functional. Also executes load requests that were received before initialization. Must be called exactly once, with the URL of the base library. Module URLs are derived from the URL of the base library by inserting the module name, preceded by a period, before the .js prefix of the base URL.
Arguments:
baseUrl : string
The URL of the base library.
opt_urlFunction : Function=
Function that creates the URL for the module file. It will be passed the base URL for module files and the module name and should return the fully-formed URL to the module file to load.
code »
load_(module)
Starts to load a module. Assumes that init() was called.
Arguments:
module : string
The name of the module.
code »
provide(moduleopt_symbolopt_object)
Registers a symbol in a loaded module. When called without symbol, registers the module to be fully loaded and executes all callbacks from pending require() callbacks for this module.
Arguments:
module : string
The name of the module. Cf. parameter module of method require().
opt_symbol : number | string=
The symbol being defined, or nothing when all symbols of the module are defined. Cf. parameter symbol of method require().
opt_object : Object=
The object bound to the symbol, or nothing when all symbols of the module are defined.
code »
require(modulesymbolcallback)
Requests the loading of a symbol from a module. When the module is loaded, the requested symbol will be passed as argument to the function callback.
Arguments:
module : string
The name of the module. Usually, the value is defined as a constant whose name starts with MOD_.
symbol : number | string
The ID of the symbol. Usually, the value is defined as a constant whose name starts with SYM_.
callback : Function
This function will be called with the resolved symbol as the argument once the module is loaded.
code »

Instance Properties

modules_ :
Provides associative access to each module and the symbols of each module that have aready been loaded (one lookup for the module, another lookup on the module for the symbol).
Code »
pendingBeforeInit_ :
Array of modules that have been requested before init() was called. If require() is called before init() was called, the required modules can obviously not yet be loaded, because their URL is unknown. The modules that are requested before init() are therefore stored in this array, and they are loaded at init() time.
Code »
pendingModuleUrls_ :
Map of module name to module url. Used to avoid fetching the same URL twice by keeping track of in-flight URLs. Note: this allows two modules to be bundled into the same file.
Code »
pending_ :
Map of module name/array of {symbol name, callback} pairs that are pending to be loaded.
Code »
urlBase_ :
The base url to load modules from. This property will be set in init().
Code »

Static Methods

goog.module.Loader.getInstance()
No description.
code »
goog.module.Loader.loaderEval_(t_)
Loads the module by evaluating the javascript text in the current scope. Uncompiled, base identifiers are visible in the global scope; when compiled they are visible in the closure of the anonymous namespace. Notice that this cannot be replaced by the global eval, because the global eval isn't in the scope of the anonymous namespace function that the jscompiled code lives in.
Arguments:
t_ : string
The javascript text to evaluate. IMPORTANT: The name of the identifier is chosen so that it isn't compiled and hence cannot shadow compiled identifiers in the surrounding scope.
code »

Static Properties

goog.module.Loader.LOAD_CALLBACK :
The globally exported name of the load callback. Matches the definition in the js_modular_binary() BUILD rule.
Code »
goog.module.Loader.instance_ :
No description.
Code »

Package module

Package Reference