The goog.module.Loader Class

goog.module.Loader()

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.

.LOAD_CALLBACK {string}

The globally exported name of the load callback. Matches the definition in the js_modular_binary() BUILD rule.

.init(baseUrl, opt_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.

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.

.provide(module, opt_symbol, opt_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.

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.

.require(module, symbol, callback)

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.

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.