Donc je suis allé de l'avant & fondamentalement copié les fonctions de Dojo addOnLoad & l'a ajouté à ma classe. Cela semble fonctionner. J'ai regardé faire un pub/sub ou un dojo.connect, mais j'ai l'impression que c'était la solution la plus propre et la plus reconnaissable.
Voici les bits nécessaires pour obtenir ça va, encore une fois dépouillées de dojo.js et branché dans ma classe:
_onto : function(arr, obj, fn){
if(!fn){
arr.push(obj);
}else if(fn){
var func = (typeof fn == "string") ? obj[fn] : fn;
arr.push(function(){ func.call(obj); });
}
},
_loaded : function() {
this._loadNotifying = true;
this._postLoad = true;
var mll = this._loaders;
for(var x = 0; x < mll.length; x++){
try{
mll[x]();
}catch(e){
throw e;
console.error("addOnLoad callback failed: " + e, e); /* let other load events fire, like the parser, but report the error */
}
}
this._loadNotifying = false;
//Make sure nothing else got added to the onload queue
//after this first run. If something did, and we are not waiting for any
//more inflight resources, run again.
if(this._postLoad && this._inFlightCount == 0 && mll.length){
this._loaded();
}
},
addOnLoad : function(/*Object?*/obj, /*String|Function?*/functionName){
this._onto(this._loaders, obj, functionName);
if(this._postLoad && !this._loadNotifying){
this._loaded();
}
}
Maine, merci pour l'exemple clair. Je vais toujours utiliser addOnLoaded comme point d'entrée, mais j'appelle simplement dojo.connect() à la place. – olore