Thanks for the suggestions.  The tough part of this is that I am using a 
library where I don't have control over the Ajax methods.   

My solution was to build a global class and then a base class over all 
other objects.   The base class would register each instance with the 
global class which would have a list of "registered" classes.   If the 
class being registered had no dependencies, then it would just call a 
ready() function of that class.   If it did have one or more dependencies, 
then it would hold off calling that object until it could verify that all 
of the dependencies were met.

The problem is, I can't get that last part to work.   Here is some code 
that I was trying, but it just doesn't work quite right.   I was hoping 
there was a better approach than what I am attempting.

    register: function( obj ) {
        this._objectList.push( obj );
 // If there are no dependencies, then no need to wait for anything
// just inform the object that it is ready to proceed.
if( isUndefinedOrNull( obj.options.dependsOn ) ) {
    if( isDefined( obj.ready ) )
obj.ready();

    // Indicate which contextual objects are ready
    if( isDefined( obj.options.contextName ))
this._contextList.include( obj.options.contextName );
 } else {
    this.addEvent( 'wait', this._depWait );
    this.fireEvent('wait', obj );
}
    },
        
    _depWait: function( obj ) {
var self = this;
var isDepsReady = true;
 //log( DEBUG, obj.element + " has dependencies ", obj.options.dependsOn );
obj.options.dependsOn.each( function( depItem, index ) {
    if( !self._contextList.contains( depItem )) {
log( DEBUG, obj.element + " waiting on " + depItem );
isDepsReady = false;
    }
})
 if( isDepsReady ) {
    // Indicate which contextual objects are ready
    if( isDefined( obj.options.contextName ))
this._contextList.include( obj.options.contextName );
    if( isDefined(obj.ready) ) {
obj.ready();
return;
    }
    }

        setTimeout( function() { es.fireEvent( 'wait', obj ) }, 1000 );
    },
    

On Monday, August 27, 2012 3:17:40 AM UTC-7, verylastminute wrote:
>
> The function you will need is https://github.com/caolan/async#paralleland 
> your load() methods will need callback arguments.
>

Reply via email to