I\'m creating a client-side dynamic blog engine. Now I need a event system to handle many actions from DOM elements and the engine. Such as the engine is loading a article,user
class SimpleEvent {
constructor() {
this.onEvent = {}
this.handler = function(funct, name) {
var owner = this
var name = name
this.onEvent[name] = funct
var remove = function() {
delete this.owner.onEvent[this.name]
delete this.owner
delete this.name
delete this.remove
}
if ((((!(remove == undefined && name == undefined)) && (remove == undefined || name == undefined)))) {
throw new Error("-_-")
} else {
return (remove == undefined || name == undefined) ? (undefined) : ({
remove: remove,
name: name
})
}
}
}
Fire() {
for (var i in this.onEvent) {
this.onEvent[i](arguments)
}
}
}