mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 11:17:05 +02:00
feat: async updates
This commit is contained in:
1 parent
5e0e80e965
commit
237f676af8
9 files changed
+248
-304
No files matched your search
@@ -0,0 +1,14 @@
|
||||
export class EventManager<Type> {
|
||||
private callbacks: Set<(data: Type) => void> = new Set();
|
||||
|
||||
on(callback: (data: Type) => void) {
|
||||
this.callbacks.add(callback);
|
||||
}
|
||||
off(callback: (data: Type) => void) {
|
||||
this.callbacks.delete(callback);
|
||||
}
|
||||
|
||||
emit(data: Type) {
|
||||
this.callbacks.forEach((callback) => callback(data));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { EventManager } from './eventManager';
|
||||
|
||||
export interface ModelTransformEventData {
|
||||
yaw?: number;
|
||||
pitch: number;
|
||||
}
|
||||
|
||||
export const modelTransformEvent = new EventManager<ModelTransformEventData>();
|
||||
Reference in new issue
Block a user