Skip to content

Commit

Permalink
chore: add more comments around how the extension adding/removing works
Browse files Browse the repository at this point in the history
  • Loading branch information
trezy committed Aug 26, 2024
1 parent 5dcd468 commit 09d0ca9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,23 @@ export const ApplicationFunction: ForwardRefRenderFunction<PixiApplication, Appl
const extensionsToHandle = [...extensions];
const extensionsState = extensionsRef.current;

// Check for extensions that have been removed from the array
for (const extension of extensionsState.values())
{
const extensionIndex = extensionsToHandle.indexOf(extension);

// If the extension is no longer in the array, we'll remove it from Pixi.js
if (extensionIndex === -1)
{
PixiExtensions.remove(extension);
extensionsState.delete(extension);
}

// Since the extension already existed in the state, we can remove it to prevent any further handling
extensionsToHandle.splice(extensionIndex, 1);
}

// Load any remaining extensions.
for (const extension in extensionsToHandle)
{
PixiExtensions.add(extension);
Expand Down

0 comments on commit 09d0ca9

Please sign in to comment.