事件容错处理

This commit is contained in:
ciniao 2023-12-22 14:33:49 +08:00
parent 47769ab6bf
commit dda11bb122

View File

@ -140,7 +140,13 @@ class _G {
}
on<T extends keyof gEventType>(event: T, callback: gEventType[T]) {
return this.event.on(event, callback);
return this.event.on(event, (...args)=>{
try{
callback.call(this, ...args);
}catch(e){
console.error(e)
}
});
}
once<T extends keyof gEventType>(event: T, callback: gEventType[T]) {