feat: async updates

This commit is contained in:
TrèsAbhi committed 2024-01-13 18:24:04 -06:00
1 parent 5e0e80e965
commit 237f676af8
9 files changed
+248 -304

No files matched your search

+14
View File
@@ -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));
}
}
+8
View File
@@ -0,0 +1,8 @@
import { EventManager } from './eventManager';
export interface ModelTransformEventData {
yaw?: number;
pitch: number;
}
export const modelTransformEvent = new EventManager<ModelTransformEventData>();