hotReload method

void hotReload()

Re-runs Module.binds and Module.exports under RegistrationStrategy.preserveExisting to refresh factory closures without losing singleton state.

No-op if the module is not in the ModuleStatus.loaded state.

Implementation

void hotReload() {
  if (_currentStatus != ModuleStatus.loaded) return;

  // Re-run binds to update factories.
  // For MVP we simply call the hook and overwrite registrations.
  // In the future SimpleBinder should support "updateFactoryOnly".

  final aware = _registrationAwareBinder;
  if (aware != null) {
    aware.runWithStrategy(RegistrationStrategy.preserveExisting, () {
      _runBindsAndExports(resetPublicScope: true);
    });
  } else {
    _runBindsAndExports(resetPublicScope: true);
  }

  // User hook
  module.hotReload(binder);
}