Skip to content

Commit

Permalink
register loaded listener with once: true
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentfretin committed Dec 12, 2024
1 parent 6e8f820 commit 7ede26d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/managed-street.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,13 @@ AFRAME.registerComponent('managed-street', {
self.pendingEntities = segmentEls;
// for each pending entity Listen for loaded event
for (const entity of self.pendingEntities) {
entity.addEventListener('loaded', () => {
self.onEntityLoaded(entity);
});
entity.addEventListener(
'loaded',
() => {
self.onEntityLoaded(entity);
},
{ once: true }
);
}
// Set up a promise that resolves when all entities are loaded
self.allLoadedPromise = new Promise((resolve) => {
Expand Down

0 comments on commit 7ede26d

Please sign in to comment.