dispose method
void
dispose()
Tears the world down: disposes every system (startup and regular),
cascades dispose() to every component / resource that mixes
ServiceMixin, clears the registry, drops event subscriptions, and
marks the world so further update calls are no-ops.
Implementation
void dispose() {
if (_disposed) return;
_disposed = true;
for (final system in List.of(_systems)) {
system.dispose(this);
}
for (final system in List.of(_startupSystems)) {
system.dispose(this);
}
// Walk every group's deps and fire ServiceMixin.dispose() on each
// service-bearing value before clearing the registry — without this,
// services attached as components or resources would leak their
// subscriptions / timers past the world's lifetime.
for (final group in registry.state.values.toList(growable: false)) {
for (final dep in group.values.toList(growable: false)) {
_disposeIfServiceMixin(dep);
}
}
_systems.clear();
_startupSystems.clear();
registry.clear();
_eventListeners.clear();
_eventBuffer.clear();
}