diff --git a/lib/amd/build/pubsub.min.js b/lib/amd/build/pubsub.min.js
index df0a8743bfd..0480eba5386 100644
--- a/lib/amd/build/pubsub.min.js
+++ b/lib/amd/build/pubsub.min.js
@@ -1,2 +1,2 @@
-define ("core/pubsub",[],function(){var a={};return{subscribe:function subscribe(b,c){a[b]=a[b]||[];a[b].push(c)},unsubscribe:function unsubscribe(b,c){if(a[b]){for(var d=0;d.\n\n/**\n * A simple Javascript PubSub implementation.\n *\n * @module core/pubsub\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n\n var events = {};\n\n /**\n * Subscribe to an event.\n *\n * @param {string} eventName The name of the event to subscribe to.\n * @param {function} callback The callback function to run when eventName occurs.\n */\n var subscribe = function(eventName, callback) {\n events[eventName] = events[eventName] || [];\n events[eventName].push(callback);\n };\n\n /**\n * Unsubscribe from an event.\n *\n * @param {string} eventName The name of the event to unsubscribe from.\n * @param {function} callback The callback to unsubscribe.\n */\n var unsubscribe = function(eventName, callback) {\n if (events[eventName]) {\n for (var i = 0; i < events[eventName].length; i++) {\n if (events[eventName][i] === callback) {\n events[eventName].splice(i, 1);\n break;\n }\n }\n }\n };\n\n /**\n * Publish an event to all subscribers.\n *\n * @param {string} eventName The name of the event to publish.\n * @param {any} data The data to provide to the subscribed callbacks.\n */\n var publish = function(eventName, data) {\n if (events[eventName]) {\n events[eventName].forEach(function(callback) {\n callback(data);\n });\n }\n };\n\n return {\n subscribe: subscribe,\n unsubscribe: unsubscribe,\n publish: publish\n };\n});\n"],"file":"pubsub.min.js"}
\ No newline at end of file
+{"version":3,"sources":["../src/pubsub.js"],"names":["events","subscribe","eventName","callback","push","unsubscribe","i","length","splice","publish","data","pendingPromise","Pending","forEach","resolve"],"mappings":"wKAsBA,uD,GAEMA,CAAAA,CAAM,CAAG,E,aAQU,QAAZC,CAAAA,SAAY,CAASC,CAAT,CAAoBC,CAApB,CAA8B,CACnDH,CAAM,CAACE,CAAD,CAAN,CAAoBF,CAAM,CAACE,CAAD,CAAN,EAAqB,EAAzC,CACAF,CAAM,CAACE,CAAD,CAAN,CAAkBE,IAAlB,CAAuBD,CAAvB,CACH,C,eAQ0B,QAAdE,CAAAA,WAAc,CAASH,CAAT,CAAoBC,CAApB,CAA8B,CACrD,GAAIH,CAAM,CAACE,CAAD,CAAV,CAAuB,CACnB,IAAK,GAAII,CAAAA,CAAC,CAAG,CAAb,CAAgBA,CAAC,CAAGN,CAAM,CAACE,CAAD,CAAN,CAAkBK,MAAtC,CAA8CD,CAAC,EAA/C,CAAmD,CAC/C,GAAIN,CAAM,CAACE,CAAD,CAAN,CAAkBI,CAAlB,IAAyBH,CAA7B,CAAuC,CACnCH,CAAM,CAACE,CAAD,CAAN,CAAkBM,MAAlB,CAAyBF,CAAzB,CAA4B,CAA5B,EACA,KACH,CACJ,CACJ,CACJ,C,CAQM,GAAMG,CAAAA,CAAO,CAAG,SAASP,CAAT,CAAoBQ,CAApB,CAA0B,CAC7C,GAAMC,CAAAA,CAAc,CAAG,GAAIC,UAAJ,CAAY,cAAgBV,CAA5B,CAAvB,CACA,GAAIF,CAAM,CAACE,CAAD,CAAV,CAAuB,CACnBF,CAAM,CAACE,CAAD,CAAN,CAAkBW,OAAlB,CAA0B,SAASV,CAAT,CAAmB,CACzCA,CAAQ,CAACO,CAAD,CACX,CAFD,CAGH,CACDC,CAAc,CAACG,OAAf,EACH,CARM,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * A simple Javascript PubSub implementation.\n *\n * @module core/pubsub\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport Pending from 'core/pending';\n\nconst events = {};\n\n/**\n * Subscribe to an event.\n *\n * @param {string} eventName The name of the event to subscribe to.\n * @param {function} callback The callback function to run when eventName occurs.\n */\nexport const subscribe = function(eventName, callback) {\n events[eventName] = events[eventName] || [];\n events[eventName].push(callback);\n};\n\n/**\n * Unsubscribe from an event.\n *\n * @param {string} eventName The name of the event to unsubscribe from.\n * @param {function} callback The callback to unsubscribe.\n */\nexport const unsubscribe = function(eventName, callback) {\n if (events[eventName]) {\n for (var i = 0; i < events[eventName].length; i++) {\n if (events[eventName][i] === callback) {\n events[eventName].splice(i, 1);\n break;\n }\n }\n }\n};\n\n/**\n * Publish an event to all subscribers.\n *\n * @param {string} eventName The name of the event to publish.\n * @param {any} data The data to provide to the subscribed callbacks.\n */\nexport const publish = function(eventName, data) {\n const pendingPromise = new Pending(\"Publishing \" + eventName);\n if (events[eventName]) {\n events[eventName].forEach(function(callback) {\n callback(data);\n });\n }\n pendingPromise.resolve();\n};\n"],"file":"pubsub.min.js"}
\ No newline at end of file
diff --git a/lib/amd/src/pubsub.js b/lib/amd/src/pubsub.js
index 7160c56397c..168dfd4f911 100644
--- a/lib/amd/src/pubsub.js
+++ b/lib/amd/src/pubsub.js
@@ -20,55 +20,50 @@
* @copyright 2018 Ryan Wyllie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define([], function() {
+import Pending from 'core/pending';
- var events = {};
+const events = {};
- /**
- * Subscribe to an event.
- *
- * @param {string} eventName The name of the event to subscribe to.
- * @param {function} callback The callback function to run when eventName occurs.
- */
- var subscribe = function(eventName, callback) {
- events[eventName] = events[eventName] || [];
- events[eventName].push(callback);
- };
+/**
+ * Subscribe to an event.
+ *
+ * @param {string} eventName The name of the event to subscribe to.
+ * @param {function} callback The callback function to run when eventName occurs.
+ */
+export const subscribe = function(eventName, callback) {
+ events[eventName] = events[eventName] || [];
+ events[eventName].push(callback);
+};
- /**
- * Unsubscribe from an event.
- *
- * @param {string} eventName The name of the event to unsubscribe from.
- * @param {function} callback The callback to unsubscribe.
- */
- var unsubscribe = function(eventName, callback) {
- if (events[eventName]) {
- for (var i = 0; i < events[eventName].length; i++) {
- if (events[eventName][i] === callback) {
- events[eventName].splice(i, 1);
- break;
- }
+/**
+ * Unsubscribe from an event.
+ *
+ * @param {string} eventName The name of the event to unsubscribe from.
+ * @param {function} callback The callback to unsubscribe.
+ */
+export const unsubscribe = function(eventName, callback) {
+ if (events[eventName]) {
+ for (var i = 0; i < events[eventName].length; i++) {
+ if (events[eventName][i] === callback) {
+ events[eventName].splice(i, 1);
+ break;
}
}
- };
+ }
+};
- /**
- * Publish an event to all subscribers.
- *
- * @param {string} eventName The name of the event to publish.
- * @param {any} data The data to provide to the subscribed callbacks.
- */
- var publish = function(eventName, data) {
- if (events[eventName]) {
- events[eventName].forEach(function(callback) {
- callback(data);
- });
- }
- };
-
- return {
- subscribe: subscribe,
- unsubscribe: unsubscribe,
- publish: publish
- };
-});
+/**
+ * Publish an event to all subscribers.
+ *
+ * @param {string} eventName The name of the event to publish.
+ * @param {any} data The data to provide to the subscribed callbacks.
+ */
+export const publish = function(eventName, data) {
+ const pendingPromise = new Pending("Publishing " + eventName);
+ if (events[eventName]) {
+ events[eventName].forEach(function(callback) {
+ callback(data);
+ });
+ }
+ pendingPromise.resolve();
+};