-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit provides the ability to properly reset the simulator (including invalidating all existing handles). This allows scenes to be re-created at any point.
- Loading branch information
Zhiquan Yeo
committed
Jun 25, 2020
1 parent
d2d4aa3
commit 48cebbf
Showing
4 changed files
with
325 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
export class HandleRegistry { | ||
private _invalidationCallbacks: Map<string, () => void> = new Map< | ||
string, | ||
() => void | ||
>(); | ||
|
||
registerHandle(objectGuid: string, invalidateCb: () => void): void { | ||
this._invalidationCallbacks.set(objectGuid, invalidateCb); | ||
} | ||
|
||
invalidateHandle(guid: string): void { | ||
if (this._invalidationCallbacks.has(guid)) { | ||
const invalidationCb = this._invalidationCallbacks.get(guid); | ||
invalidationCb(); | ||
} | ||
} | ||
|
||
deleteHandle(guid: string): void { | ||
this.invalidateHandle(guid); | ||
this._invalidationCallbacks.delete(guid); | ||
} | ||
|
||
invalidateAllHandles(): void { | ||
this._invalidationCallbacks.forEach((invalidationCb) => { | ||
invalidationCb(); | ||
}); | ||
} | ||
|
||
deleteAllHandles(): void { | ||
this.invalidateAllHandles(); | ||
this._invalidationCallbacks.clear(); | ||
} | ||
} |
Oops, something went wrong.