2016-04-07 19:03:49 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
let listeners = [];
|
|
|
|
|
2016-04-09 18:54:23 +02:00
|
|
|
function unlisten(messageClass) {
|
|
|
|
listeners[messageClass] = [];
|
|
|
|
}
|
|
|
|
|
2016-04-07 19:03:49 +02:00
|
|
|
function listen(messageClass, handler) {
|
|
|
|
if (!(messageClass in listeners)) {
|
|
|
|
listeners[messageClass] = [];
|
|
|
|
}
|
|
|
|
listeners[messageClass].push(handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
function notify(messageClass, message) {
|
|
|
|
if (!(messageClass in listeners)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let handler of listeners[messageClass]) {
|
|
|
|
handler(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
Success: 1,
|
|
|
|
Error: 2,
|
2016-04-12 18:17:46 +02:00
|
|
|
Info: 3,
|
|
|
|
Authentication: 4,
|
2016-04-12 23:49:46 +02:00
|
|
|
SettingsChange: 5,
|
2016-05-10 10:57:59 +02:00
|
|
|
TagsChange: 6,
|
2016-04-07 19:03:49 +02:00
|
|
|
|
|
|
|
notify: notify,
|
|
|
|
listen: listen,
|
2016-04-09 18:54:23 +02:00
|
|
|
unlisten: unlisten,
|
2016-04-07 19:03:49 +02:00
|
|
|
};
|