mediawiki.notify: Simplify callback by using .then()
authorFomafix <fomafix@googlemail.com>
Wed, 13 Aug 2014 21:31:48 +0000 (21:31 +0000)
committer[[mw:User:Fomafix]] <gerritpatchuploader@gmail.com>
Wed, 13 Aug 2014 21:31:48 +0000 (21:31 +0000)
Change-Id: Ifff25534d716721ff1d2d4484dbd0f63161ecb43

resources/src/mediawiki/mediawiki.notify.js

index 743d651..c1e1dab 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * @class mw.plugin.notify
  */
-( function ( mw, $ ) {
+( function ( mw ) {
        'use strict';
 
        /**
         * @return {jQuery.Promise}
         */
        mw.notify = function ( message, options ) {
-               var d = $.Deferred();
                // Don't bother loading the whole notification system if we never use it.
-               mw.loader.using( 'mediawiki.notification', function () {
-                       // Call notify with the notification the user requested of us.
-                       d.resolve( mw.notification.notify( message, options ) );
-               }, d.reject );
-               return d.promise();
+               return mw.loader.using( 'mediawiki.notification' )
+                       .then( function () {
+                               // Call notify with the notification the user requested of us.
+                               return mw.notification.notify( message, options );
+                       } );
        };
 
        /**
@@ -25,4 +24,4 @@
         * @mixins mw.plugin.notify
         */
 
-}( mediaWiki, jQuery ) );
+}( mediaWiki ) );