gallery.accords-library.com/client/js/events.js

37 lines
662 B
JavaScript
Raw Normal View History

2016-04-07 17:03:49 +00:00
'use strict';
let listeners = [];
function unlisten(messageClass) {
listeners[messageClass] = [];
}
2016-04-07 17:03:49 +00: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,
Info: 3,
Authentication: 4,
2016-04-12 21:49:46 +00:00
SettingsChange: 5,
2016-05-10 08:57:59 +00:00
TagsChange: 6,
2016-04-07 17:03:49 +00:00
notify: notify,
listen: listen,
unlisten: unlisten,
2016-04-07 17:03:49 +00:00
};