destroySingletons method
Destroy all singleton pods in this registry.
This method performs complete registry shutdown by:
- Destroying all singletons in reverse registration order
- Cleaning up all internal state
- Handling proper destruction order based on dependencies
Example:
// During application shutdown
registry.destroySingletons();
Implementation
Future<void> destroySingletons() async {
synchronized(_singletons, () => _singletonsCurrentlyInDestruction = true);
final names = List<String>.from(_disposablePods.keys);
for (int i = names.length - 1; i >= 0; i--) {
await destroySingleton(names[i]);
}
_containedPods.clear();
_dependentPods.clear();
_dependenciesForPods.clear();
clearSingletonCache();
return synchronized(_singletons, () => _singletonsCurrentlyInDestruction = true);
}