destroySingleton method

  1. @protected
Future<void> destroySingleton(
  1. String name
)
inherited

Destroy the given pod. Delegates to destroyPod if a corresponding disposable pod instance is found.

This method handles the complete destruction lifecycle including:

  • Removal from singleton caches
  • Dependency cleanup
  • Disposable pod destruction
  • Contained pod destruction

name: The name of the pod to destroy

Example:

registry.destroySingleton('userService');

Implementation

@protected
Future<void> destroySingleton(String name) async {
  // Destroy the corresponding DisposablePod instance
  var pod = _disposablePods[name];
  synchronized(_disposablePods, () => pod = _disposablePods.remove(name));

  if(pod != null) {
    await destroyPod(name, pod!.getValue());
  }

  // Remove a registered singleton of the given name, if any
  removeSingleton(name);
}