goog.module.ModuleManager
Classgoog.module.ModuleManager
> goog.Disposable
goog.module.ModuleManager()
The ModuleManager keeps track of all modules in the environment. Since modules may not have their code loaded, we must keep track of them.
.CORRUPT_RESPONSE_STATUS_CODE
{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.
goog.module.ModuleManager.CallbackType
EnumThe type of callbacks that can be registered with the module manager,. … more
goog.module.ModuleManager.FailureType
EnumThe possible reasons for a module load failure callback being fired. … more
.addOnDisposeCallback(callback, opt_scope)
Inherited from goog.Disposable
.
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
callback
{!Function
}
opt_scope
{Object
=}
.afterLoadModuleCode(id)
Method called just after module code is loaded
id
{string
}
.beforeLoadModuleCode(id)
Method called just before a module code is loaded.
id
{string
}
.creationStack
{string
}Inherited from goog.Disposable
.
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
.dispose()
Inherited from goog.Disposable
.
Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
void
}
.disposeInternal()
[protected]Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend {@code goog.Disposable} should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' {@code disposeInternal} method. Everywhere else the public {@code dispose} method must be used. For example:
mypackage.MyClass = function() { goog.base(this); // Constructor logic specific to MyClass. ... }; goog.inherits(mypackage.MyClass, goog.Disposable); mypackage.MyClass.prototype.disposeInternal = function() { goog.base(this, 'disposeInternal'); // Dispose logic specific to MyClass. ... };
.execOnLoad(moduleId, fn, opt_handler, opt_noLoad, opt_userInitiated,
opt_preferSynchronous)
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.
moduleId
{string
}
fn
{Function
}
opt_handler
{Object
=}
opt_noLoad
{boolean
=}
opt_userInitiated
{boolean
=}
opt_preferSynchronous
{boolean
=}
goog.module.ModuleLoadCallback
}
.getDisposed
[deprecated]Deprecated. Use {@link #isDisposed} instead.
Inherited from goog.Disposable
.
boolean
}
.getLoader()
Gets the application-specific module loader.
goog.module.AbstractModuleLoader
}
.getModuleContext()
Gets the module context to use to initialize the module.
Object
}
.getModuleInfo(id)
Gets a module info object by id.
id
{string
}
goog.module.ModuleInfo
}
.isActive()
Determines if the ModuleManager is active
boolean
}
.isDisposed()
Inherited from goog.Disposable
.
boolean
}
.isModuleLoading(id)
Gets whether a module is currently loading or in the queue, waiting to be loaded.
id
{string
}
boolean
}
.isUserActive()
Determines if the ModuleManager is user active
boolean
}
.load(moduleId, opt_userInitiated)
Loads a module, returning a goog.async.Deferred for keeping track of the result.
moduleId
{string
}
opt_userInitiated
{boolean
=}
goog.async.Deferred
}
.loadMultiple(moduleIds, opt_userInitiated)
Loads a list of modules, returning a goog.async.Deferred for keeping track of the result.
moduleIds
{Array
.<string
>}
opt_userInitiated
{boolean
=}
Object
.<!goog.async.Deferred
>}
.prefetchModule(id)
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.
id
{string
}
.preloadModule(id, opt_timeout)
Preloads a module after a short delay.
id
{string
}
opt_timeout
{number
=}
goog.async.Deferred
}
.registerCallback(types, fn)
The function to call if the module manager is in error.
types
{goog.module.ModuleManager.CallbackType
|Array
.<goog.module.ModuleManager.CallbackType
>}
fn
{Function
}
.registerDisposable(disposable)
Inherited from goog.Disposable
.
Associates a disposable object with this object so that they will be disposed together.
disposable
{goog.disposable.IDisposable
}
.registerInitializationCallback(fn, opt_handler)
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.
fn
{Function
}
opt_handler
{Object
=}
.registerLateInitializationCallback(fn, opt_handler)
Register a late initialization callback for the currently loading module. Callbacks registered via this function are executed similar to {@see registerInitializationCallback}, but they are fired after all initialization callbacks are called.
fn
{Function
}
opt_handler
{Object
=}
.setAllModuleInfo(infoMap)
Sets the module info for all modules. Should only be called once.
infoMap
{Object
.<Array
.<string
>>}
.setAllModuleInfoString(opt_info, opt_loadingModuleIds)
Sets the module info for all modules. Should only be called once. Also marks modules that are currently being loaded.
opt_info
{string
=}
opt_loadingModuleIds
{Array
.<string
>=}
.setBatchModeEnabled(enabled)
Sets the batch mode as enabled or disabled for the module manager.
enabled
{boolean
}
.setLoaded(id)
Records that a 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.
id
{string
}
.setLoader(loader)
Sets the application-specific module loader.
loader
{goog.module.AbstractModuleLoader
}
.setModuleConstructor(fn)
Sets the constructor to use for the module object for the currently loading module. The constructor should derive from {@see goog.module.BaseModule}.
fn
{Function
}
.setModuleContext(context)
Sets the module context to use to initialize the module.
context
{Object
}
.setModuleUris(moduleUriMap)
Sets the module uris.
moduleUriMap
{Object
}