szurubooru/client/js/events.js

29 lines
512 B
JavaScript
Raw Normal View History

2016-04-07 19:03:49 +02:00
'use strict';
let listeners = [];
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,
Authentication: 3,
notify: notify,
listen: listen,
};