https://bugzilla.wikimedia.org/show_bug.cgi?id=65428

--- Comment #8 from Krinkle <[email protected]> ---
(In reply to Tisza Gergő from comment #5)
> Hard to tell how exactly it should be done without knowing how you track
> when all plugins are loaded, but probably something along the line of all
> plugins returning a promise which is used to create a master promise saying
> "all plugins loaded".
> 
> E.g.
> 
> var pluginLoadingPromises = [];
> 
> for ( plugin in this.plugins ) {
>     pluginLoadingPromises.push( plugin.getLoadingPromise() );
> }
> 
> $.when.apply( $.when, pluginLoadingPromises ).then( allPluginsLoadedCallback
> );


If you end up using $.when, please get it right.

$.when.apply( $, promises );

or:

$.when.apply( null, promises );

not:

$.when.apply( $.when, promises );



Also, I'd recommend attaching to .done() instead of .then() if you don't need
*another* deferred to be instantiated with all handlers proxied. Unnecessary
overhead.

Alternatively, if you have control over the flow, you can chain deferreds
instead of queueing them up in an array:

$.when(
 thing1,
 thing2
).then( function ( data1, data2 ) {
 return $.ajax( url, { x: data1.y + data2.z } );
}).then( function ( response ) {
 return response.success;
}).etc.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to