COMM.Queue
Description
COMM.Queue executes javascript blocks in a managed queue.COMM.Queue is used by COMM.Transporter and JSLoader to continue javascript command execution after a XMLHttpRequest finishes.
COMM.Queue runs as a single instance, dan't try to reconstruct it.
Inherits from:
- COMM.Queue < HApplication < HClass < Object
Implements:
Constructor Method
The constructor is invoked, when a new instance of COMM.Queue is created.
To create a new instance use COMM.Queue.nu( ) or new COMM.Queue( ).
constructor( )
The constructor takes no arguments and starts queue flushing automatically.
Class Methods
implement( interface )
Inherited from: HClass
Description
Copies the members of interface to a HClass or a class inherited from HClass.Usage:
Defines an interface:// Create an interface class that calculates the area var AreaInterface = HClass.extend({ constructor: null, area: function() { return this.getWidth() * this.getHeight(); } });// Create a class that contains the coordinates of a rectangle. var Rectangle = HClass.extend({ constructor: function( x, y, width, height ) { this.x = x; this.y = y; this.width = width; this.height = height; }, getWidth: function() { return this.width; }, getHeight: function() { return this.height; } });
// Makes the Rectangle class implement the AreaInterface Rectangle.implement( AreaInterface );
nu( )
Inherited from: HClass
Class members:
Description
nu is a protected class method.
It does the same thing as the new keyword, but it is a class method.
Parameters:
Any parameters are passed on to theconstructor method.
Usage:
Creates a classMyClass, then creates two instances of it:
myClassInstance1 and myClassInstance2. The end result is the same.
var MyClass = HClass.extend({ name: 'Foo', constructor: function( param1, param2 ){ var logMsg = [ 'param1:', param1, 'param2:', param2, 'name:', this.name ]; console.log( logMsg.join(' ') ); } });
// Construction using the new keyword: var myClassInstance1 = new MyClass( 'one', 'two' );
// Construction using the nu method: var myClassInstance2 = MyClass.nu( 'one', 'two' );However, when extending in place, the benefits of the
nu method
become obvious.
// Extending in place with the new keyword: var myExtendedClassInstance1 = new ( MyClass.extend({ name: 'Bar' }) )( 'one', 'two' );
// The same as above, but using the nu method: var myExtendedClassInstance2 = MyClass.extend({ name: 'Bar' }).nu( 'one', 'two' );
extend( instance, static )
Inherited from: HClass
Description
The class method used to extend a class.If the member name constructor is defined as null instead of a function
block in the instance object block, the class is defined as a singleton
(single instance class).
Parameters:
instance |
The object that defines the class instance members. |
|---|---|
static |
The object that defines the static class members. |
Returns:
Returns the extended class object.Usage:
var Point = HClass.extend({ constructor: function( x, y ) { this.x = x; this.y = y; } }); var Rectangle = Point.extend({ // Instance members: constructor: function( x, y, width, height ) { this.base( x, y ); this.width = width; this.height = height; }, getWidth: function() { return this.width; }, getHeight: function() { return this.height; } }, // Class Members { description: "this is a Rectangle", getClass: function() { return this; } });
Instance Methods
pause( )
Description
Pauses the queue.Use to stop execution, if some data or code needs to be loaded that the
rest of the queue depends on.
Typically called before an XMLHttpRequest with the onSuccess
event defined to call resume when the request is done.
pushEval( evalStr )
Like push, but uses the code block as a string to be
passed on as an evaluated anonymous function.
resume( )
Description
Resumes queue flushing.Use to resume execuption, when some depending code for the rest
of the queue has been loaded.
Typically on an XMLHttpRequest onSuccess event.
push( function, arguments )
Description
Adds an item to the end of the queue.Use to make the given function with its
optional arguments the last item to flush.
Parameters:
function |
An anonymous function. Contains the code to execute. |
|---|
arguments |
Optional_ arguments to pass on to the function |
|---|
unshiftEval( evalStr, arguments )
Like unshift, but uses the code block as a string to be
passed on as an evaluated anonymous function.
flush( )
Description
Flushes the queue until stopped.Iterates through the commandQueue and calls each function.
Removes items from the queue after execution.
unshift( function, arguments )
Description
Adds an item to the beginning of the queue.Use to make the given function with its
optional arguments the next item to flush.
Parameters:
function |
An anonymous function. Contains the code to execute. |
|---|
arguments |
Optional_ arguments to pass on to the function |
|---|
onIdle( )
Checks periodically, if the queue needs flushing.
setValue( value )
Inherited from: HValueResponder
Description
Assigns the object a new value. Extend it, if your component needs to do validation of the new value. ForHControl instances, extend HControl#refreshValue to do something when
the value has been set.
Parameter
value |
The new value. Allowed values depend on the component type and other usage of the bound HValue instance self.valueObj. |
|---|
Returns
self (COMM.Queue#)
valueDiffers( value )
Inherited from: HValueResponder
Description
Checks, if the value given as parameter differs fromvalue.
Parameters
value |
The value to be tested. |
|---|
Returns
A boolean true (different) or false (same).setValueObj( valueObj )
Inherited from: HValueResponder
Description
Binds an HValue compatible instance to the component's valueObj. Also callssetValue. It should not be called from user code, instead
use the HValue instance method bind.
Parameter
aValueObj |
The HValue instance object to bind. |
|---|
Returns
self (COMM.Queue#)
removeView( viewId )
Inherited from: HApplication
Description
Removes the view of the givenviewId.
Call this if you need to remove a child view from its parent without destroying its view, making it in effect a view without parent. Useful, for example, for moving a view from one parent component to another when dragging a component to a droppable container.
Parameters
viewId |
The view ID. |
|---|
destroyView( viewId )
Inherited from: HApplication
Description
Removes and destructs the view of the givenviewId.
Call this if you need to remove a child view from its parent, destroying its child views recursively and removing all of the DOM elements too.
Parameters
viewId |
The view ID. |
|---|
die( )
Inherited from: HApplication
Description
The destructor of theHApplication instance.
Stops this application and destroys all its views recursively.
addView( view )
Inherited from: HApplication
Description
Adds a view to the app,HView defines an indentical structure for subviews.
Called from inside the HView constructor and should be automatic for all
components that accept the parent parameter, usually the second argument,
after the HRect instance.
Parameters
view |
Usually self (COMM.Queue#) inside HView -derived components. |
|---|
Returns
The view ID.buildParents( viewId )
Inherited from: HApplication
Description
Used by addView to build aself.parents array of parent classes.
Parameters
viewId |
The target view's ID. |
|---|
destroyAllViews( )
Inherited from: HApplication
Description
Destructs all views but doesn't destroy theHApplication instance.
Destroys all the views added to this application but doesn't destroy the application itself.
toString( )
Inherited from: HClass
Protected instance method, returns the instance represented as a String.
valueOf( )
Inherited from: HClass
Protected instance method, returns the value of an instance.
base( )
Inherited from: HClass
This method can be called from any other method to invoke that method's parent
Other Instance Members
STRINGS = { ERR: 'COMM.Queue Error: ', JS_EXEC_FAIL: 'Failed to execute the Javascript function: ', REASON: ' Reason:' }
A Group of localizable strings; errors and warnings.
elemId = 0
Inherited from: HApplication
prototype = { }
Inherited from: Object
Description
Theprototype member of Object defines the instance members.
These are copied to the instance object when the new keyword is called.