Files
MYPOM/6.0/общее/100.События.js

37 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function События(uuid)
{
this.создать = function()
{
this.обработчики = [];
this.обработчики = {};
};
this.подписать = function(обработчик, имя)
{
let указатель = имя || uuid();
this.обработчики[указатель] = обработчик;
};
this.отписать = function(обработчик) {
for (var указатель in this.обработчики) {
let обр = this.обработчики[указатель];
if (обр == обработчик)
{
delete this.обработчики[указатель];
return;
}
}
};
this.уведомить = function(событие) {
for (var номер in this.обработчики)
{
var обработчик = this.обработчики[номер];
обработчик.обработатьСобытие(событие);
}
};
// Конструктор.
this.создать();
}