@epicgames-ps/lib-pixelstreamingfrontend-ue5.4
Version:
Frontend library for Unreal Engine 5.4 Pixel Streaming
30 lines (24 loc) • 710 B
text/typescript
// Copyright Epic Games, Inc. All Rights Reserved.
export type UnregisterFunction = () => void;
export class EventListenerTracker {
private unregisterCallbacks: UnregisterFunction[];
constructor() {
this.unregisterCallbacks = [];
}
/**
* Add a new callback that is executed when unregisterAll is called.
* @param callback
*/
addUnregisterCallback(callback: UnregisterFunction) {
this.unregisterCallbacks.push(callback);
}
/**
* Execute all callbacks and clear the list.
*/
unregisterAll() {
for (const callback of this.unregisterCallbacks) {
callback();
}
this.unregisterCallbacks = [];
}
}