JavaScript – lubiÄ™ to
Mirek Szajowski
JavaScript ¨C lubi? to
Programista:
Agenda
?
J?zyk
?
Modu?owo??
?
Zale?no?ci/biblioteki zewn?trzne
?
CSS
?
Testy/ Linty
?
Narz?dzia do budowania
?
Frameworks
WWW.STREAMSOFT.PL
J?zyk
WWW.STREAMSOFT.PL
J?zyk -ECMAScript 5
function EventBus() {
this.listeners = [];
}
EventBus.prototype.addListener = function (listener) {
let index = this.listeners.indexOf(listener);
if (index !== -1) {
throw new Error('Listener already added');
}
this.listeners.push(listener);
};
EventBus.prototype.removeListener = function (listener) {
let index = this.listeners.indexOf(listener);
this.listeners.splice(index, 1);
};
EventBus.prototype.fire = function (eventName, eventData) {
for (var i = 0; i < this.listeners.length; i++) {
var listener = this.listeners[i];
if (listener.eventName === eventName) {
listener.handle(eventData);
}
var eb = new EventBus();
}
var listener = {
};
eventName: 'RowSelected', handle: function (data) {
console.log('RowSelected: ', data);
}
};
eb.addListener(listener);
eb.fire('RowSelected', {id: 1});
eb.fire('RowSelected', {id: 2});
eb.removeListener(listener);
WWW.STREAMSOFT.PL
J?zyk -ECMAScript 5
WWW.STREAMSOFT.PL
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- javascript array to string
- javascript string to datetime
- javascript date to string
- javascript convert to string
- javascript integer to string
- javascript decimal to integer
- javascript date to formatted string
- javascript decimal to int
- javascript convert to decimal
- javascript cast to int
- javascript date to iso format
- javascript hex to int