disposeModule<T extends EasyModule> static method

Future<void> disposeModule<T extends EasyModule>()

Disposes a module and reloads all modules that depend on it.

This method disposes the module and then reloads all modules that depend on it. After disposing, it will:

  1. Reset the module's state and injector
  2. Re-process its imports to ensure dependencies are properly linked
  3. Recursively reload any modules that depend on this one

Example:

await EasyDI.disposeModule<UserModule>();

Throws an Exception if the module is not found in the manager.

Implementation

static Future<void> disposeModule<T extends EasyModule>() async {
  final module = _modules[T] as T?;
  if (module == null) {
    throw Exception('[$EasyDI] module "$T" not found.');
  }

  await module.reset();
  _proccessModuleImports<T>(module);
  await _reloadModulesThatDependOn(module);
}