How can you listen to world.spaces.loadSpace?

I’m just wondering if you could listen by default to world.spaces.loadSpace(${spaceName})

As that could be very helpful for keeping track of loading state etc…

If not I guess I could dispatch a custom event.

Never mind! I found what I was looking for in the docs :slight_smile:

world.events.addListener(world.events.globalId, ecs.events.ACTIVE_SPACE_CHANGE, () => {
console.log(‘Active space change’);
});

Actually it doesn’t seem to be recognized?

Just spoke with the engineering team. This is the result of a bug. It will be fixed in the next runtime release.

awesome, thank you for your quick response ! In the meantime I just dispatch a custom event right before which essentially does the same thing.

1 Like

Found the same bug, needed to dispatch AFTER Space loads, luckily loading a space doesn’t stop the loader code, so I just dispatched right after the space load. (At least in my case where loader lives in a shared space, so maybe if loader has to unload it interrupts it, haven’t tested) I’ll leave this insight in case someone else stumbles with this