~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://danielfriesen.name/]
On 2014-09-17 12:36 AM, Niklas Laxström wrote:
mw.loader.using( 'ext.pollNY.lightBox', function() { LightBox.init(); } );
((Any other code using LightBox.* should probably do the same thing, athough mw.loader.using is using jQuery's "promises" (I really want to call this something else, since jQuery doesn't implement proper promises) incorrectly so I'm not sure how well that will work))
That's difficult to read with the multiple levels of nesting with parenthesis.
- jQuery's promises are not compatible with Promises/A+ or ES6 promises spec.
** How is this relevant?
They implement barely 1/3 of the fundamentals of what a promise is, missing out on nearly everything that makes promises a powerful tool, so I just loath the idea of EVER using the term promise to refer to them.
- mw.loader.using promises incorrectly?
** How? Is there a bug report? What issues does it cause?
Sorry, it looks like I'm probably wrong about this.
I looked up mw.loader.using's code when I was writing the example, but I didn't see the complex handling in request, filter, and mw.loader.work.
So when I saw the pattern in mw.loader.using that went... 1. create brand new deferred 2. resolve if all deps are ready 3. reject if any are missing 4. otherwise call request()
...It looked like there might be a race condition where calling mw.loader.using again before the script loading was complete would cause a second HTTP request to be triggered instead of waiting for the first to complete.