reset method
Resets all managed nodes and references in this container without permanently disposing the container itself.
Fires all onDispose callbacks on managed ZenithRefs, disposes all
managed ZenithNodes, and clears internal storage maps.
Set purgeZeroize to wipe current secure values before releasing them.
Useful for in-place user logout or session teardown without replacing the ZenithContainer instance.
Safe to call on a disposed container (no-op).
Implementation
Future<void> reset({bool purgeZeroize = false}) async {
if (_isDisposed) {
return;
}
for (final ref in _activeRefs.toList(growable: false)) {
ref._dispose();
}
for (final node in _nodes.values.toList(growable: false)) {
node.dispose(purgeZeroize: purgeZeroize);
}
_activeRefs.clear();
_refs.clear();
_nodes.clear();
await _cleanupFuture;
}