Zimlet JavaScript API Reference - AjxDispatcher

Class AjxDispatcher


This static class serves as a central location for registering and calling public API methods. For example, the registration of a public API method for pulling up the compose form might look something like this:

AjxDispatcher.register("Compose", "Mail", new AjxCallback(this, this.doAction));
and a client call of it like this:
AjxDispatcher.run("Compose", {action:ZmOperation.NEW_MESSAGE, inNewWindow:false});
Registration will most likely need to happen in a constructor, when 'this' is available, since you'll most likely want the function call to happen in that object's context.

A package can also register a callback to be run once the package has loaded. One use case for that is to register newly-defined classes as drop targets. There is a wrapper method around AjxPackage.require() that will call that method and then run the post-load callback (if any):

AjxDispatcher.require("Calendar");


Defined in: AjxDispatcher.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
<static>  
AjxDispatcher.setPackageLoadFunction
<static>  
AjxDispatcher.setPostLoadFunction
<static>  
AjxDispatcher.setPreLoadFunction
Method Summary
Method Attributes Method Name and Description
<static>  
AjxDispatcher.addPackageLoadFunction(pkg, callback)
Adds a function to be called after the given package has been loaded.
<static>  
AjxDispatcher.addPostLoadFunction(callback)
Adds a function to be called after a package has been loaded.
<static>  
AjxDispatcher.addPreLoadFunction(callback)
Adds a function to be called while a package is being loaded.
<static>  
AjxDispatcher.enableLoadFunctions(enabled)
Enables/disables the running of the pre/post load functions.
<static>  
AjxDispatcher.loaded(pkg)
Checks if the given package has been loaded.
<static>  
AjxDispatcher.registerMethod(method, pkg, callback)
Registers an API method so that it may be called.
<static>  
AjxDispatcher.require(pkg, async, callback, args, preLoadOk)
Loads the given package, and runs its requested post-load callback.
<static>  
AjxDispatcher.setLoaded(pkg, loaded)
Programmatically sets whether the given packages has been loaded.
Class Detail
AjxDispatcher()

Author: Conrad Damon.
Field Detail
<static> AjxDispatcher.setPackageLoadFunction
Deprecated:
Use addPackageLoadFunction instead.

<static> AjxDispatcher.setPostLoadFunction
Deprecated:
Use addPostLoadFunction instead.

<static> AjxDispatcher.setPreLoadFunction
Deprecated:
Use addPreLoadFunction instead.
Method Detail
<static> AjxDispatcher.addPackageLoadFunction(pkg, callback)
Adds a function to be called after the given package has been loaded.
Parameters:
{string} pkg
the name of package
{AjxCallback} callback
the callback to run after package has loaded

<static> AjxDispatcher.addPostLoadFunction(callback)
Adds a function to be called after a package has been loaded. A typical use is to clear a "Loading..." screen.
Parameters:
{AjxCallback} callback
the callback to run after package has loaded

<static> AjxDispatcher.addPreLoadFunction(callback)
Adds a function to be called while a package is being loaded. A typical use is to display a "Loading..." screen.
Parameters:
{AjxCallback} callback
the callback to run after package has loaded

<static> AjxDispatcher.enableLoadFunctions(enabled)
Enables/disables the running of the pre/post load functions.
Parameters:
{boolean} enabled
if true, run pre/post load functions

<static> {boolean} AjxDispatcher.loaded(pkg)
Checks if the given package has been loaded.
Parameters:
{string} pkg
the name of package
Returns:
{boolean} true if the package is loaded

<static> AjxDispatcher.registerMethod(method, pkg, callback)
Registers an API method so that it may be called.
Parameters:
{string} method
the name of the API method
{string} pkg
the name of required package(s)
{AjxCallback} callback
the callback to run for this API call

<static> AjxDispatcher.require(pkg, async, callback, args, preLoadOk)
Loads the given package, and runs its requested post-load callback. Clients should be careful not to mix async and sync calls for the same package, in order to avoid race conditions.
Parameters:
{string} pkg
the name of the API method
{boolean} async
if true, load package asynchronously
{AjxCallback} callback
the callback to run after pkg load
{array} args
the args to pass to callback
{boolean} preLoadOk
if true, okay to run registered pre-load function

<static> {boolean} AjxDispatcher.setLoaded(pkg, loaded)
Programmatically sets whether the given packages has been loaded. Use with care!
Parameters:
{string} pkg
the name of package
loaded
Returns:
{boolean} if true, the package is loaded

Documentation generated by JsDoc Toolkit 2.3.0 on Tue Jun 28 2016 21:01:25 GMT-0400 (EDT)