UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

33 lines (31 loc) 733 B
class EventHandle { constructor(handler, name, callback, scope, once = false){ this._removed = false; this.handler = handler; this.name = name; this.callback = callback; this.scope = scope; this._once = once; } off() { if (this._removed) return; this.handler.offByHandle(this); } on(name, callback, scope = this) { return this.handler._addCallback(name, callback, scope, false); } once(name, callback, scope = this) { return this.handler._addCallback(name, callback, scope, true); } set removed(value) { if (!value) return; this._removed = true; } get removed() { return this._removed; } toJSON(key) { return undefined; } } export { EventHandle };