goog.module.ModuleManager
Provided By | |
---|---|
Extends | |
All Implemented Interfaces |
The ModuleManager keeps track of all modules in the environment. Since modules may not have their code loaded, we must keep track of them.
new ModuleManager()
Parameters | None. |
---|
Instance Methods
this.addExtraEdge( fromModule, toModule ) → void
void
Register an extra runtime module dependency. After an extra edge is added, any subsequent calls to load or loadMultiple will fetch toModule if the fromModule was loaded.
The mechanism for this is implementation dependent. If the implementation does not support extra edges, it will throw an error.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.beforeLoadModuleCode( id ) → void
void
Method called just before module code is loaded.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.dispose() → ?
?
Disposes of the object and its resources.
Specified by | ||
---|---|---|
Parameters | None. | |
Returns |
|
this.execOnLoad( moduleId, fn, opt_handler, opt_noLoad, opt_userInitiated, opt_preferSynchronous ) → goog.module.ModuleLoadCallback
goog.module.ModuleLoadCallback
Requests that a function be called once a particular module is loaded. Client code can use this method to safely call into modules that may not yet be loaded. For consistency, this method always calls the function asynchronously -- even if the module is already loaded. Initiates loading of the module if necessary, unless opt_noLoad is true.
Overrides | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||||||||||||||||||
Returns |
|
this.getLoader() → (goog.module.AbstractModuleLoader|null)
(goog.module.AbstractModuleLoader|null)
Gets the application-specific module loader.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getModuleContext() → (Object|null)
(Object|null)
Gets the module context to use to initialize the module.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getModuleInfo( id ) → goog.module.ModuleInfo
goog.module.ModuleInfo
Gets a module info object by id.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.isActive() → boolean
boolean
Determines if the ModuleManager is active
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isDisposed() → boolean
boolean
Specified by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isModuleLoading( id ) → boolean
boolean
this.isUserActive() → boolean
boolean
Determines if the ModuleManager is user active
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.load( moduleId, opt_userInitiated ) → IThenable
IThenable
Loads a list of modules, returning a map of IThenables for keeping track of the results.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.prefetchModule( id ) → void
void
Prefetches a JavaScript module and its dependencies, which means that the module will be downloaded, but not evaluated. To complete the module load, the caller should also call load or execOnLoad after prefetching the module.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.preloadModule( id, opt_timeout ) → IThenable
IThenable
Preloads a module after a short delay.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.registerCallback( types, fn ) → void
void
The function to call if the module manager is in error.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.registerInitializationCallback( fn, opt_handler ) → void
void
Register an initialization callback for the currently loading module. This should only be called by script that is executed during the evaluation of a module's javascript. This is almost equivalent to calling the function inline, but ensures that all the code from the currently loading module has been loaded. This makes it cleaner and more robust than calling the function inline.
If this function is called from the base module (the one that contains the module manager code), the callback is held until #setAllModuleInfo is called, or until #setModuleContext is called, whichever happens first.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.registerLateInitializationCallback( fn, opt_handler ) → void
void
Register a late initialization callback for the currently loading module. Callbacks registered via this function are executed similar to registerInitializationCallback, but they are fired after all initialization callbacks are called.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.removeExtraEdge( fromModule, toModule ) → void
void
this.setAllModuleInfo( infoMap ) → void
void
this.setAllModuleInfoString( opt_info, opt_loadingModuleIds ) → void
void
Sets the module info for all modules. Should only be called once. Also marks modules that are currently being loaded.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.setBatchModeEnabled( enabled ) → void
void
Sets the batch mode as enabled or disabled for the module manager.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.setConcurrentLoadingEnabled( enabled ) → void
void
Sets the concurrent loading mode as enabled or disabled for the module manager. Requires a moduleloader implementation that supports concurrent loads. The default goog.module.ModuleLoader does not.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.setLoaded() → void
void
Records that the currently loading module was loaded. Also initiates loading the next module if any module requests are queued. This method is called by code that is generated and appended to each dynamic module's code at compilation time.
Overrides | |
---|---|
Parameters | None. |
this.setLoader( loader ) → void
void
Sets the application-specific module loader.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setModuleConstructor( fn ) → void
void
Sets the constructor to use for the module object for the currently loading module. The constructor should derive from goog.module.BaseModule.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.setModuleContext( context ) → void
void
Sets the module context to use to initialize the module.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.setModuleTrustedUris( moduleUriMap ) → void
void
Sets the module uris.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
Instance Properties
this.moduleInfoMap → Object<string, goog.module.ModuleInfo>
Object<string, goog.module.ModuleInfo>
A mapping from module id to ModuleInfo object.
Static Functions
ModuleManager.getInstance() → goog.loader.AbstractModuleManager
goog.loader.AbstractModuleManager
Parameters | None. | |
---|---|---|
Returns |
|
Static Properties
ModuleManager.CORRUPT_RESPONSE_STATUS_CODE → number
number
A non-HTTP status code indicating a corruption in loaded module. This should be used by a ModuleLoader as a replacement for the HTTP code given to the error handler function to indicated that the module was corrupted. This will set the forceReload flag on the loadModules method when retrying module loading.
Compiler Constants
goog.module.ModuleManager.SUBTRACTIVE_MODULE_LOADING → boolean
boolean
Whether subtractive module loading is enabled. The main difference is the module graph is no longer in the client, i.e., setAllModuleInfoString is never been called. Instead, the module manager will keep track of the already loaded modules, and add them to the subsequent loader requests. The serving system is able to figure out the list of desired modules.
The default is false, but new code is encouraged to use this. Search, Gmail, and many Google applications has been using subtractive module loading for years and see significantly performance benefits.