onClose method

  1. @override
void onClose()
override

Callback invoked when the controller is being removed from Levit.

This method triggers the cleanup of all objects registered via autoDispose.

Always call super.onClose() if overriding. Once closed, the controller is considered disposed and cannot be reused.

Implementation

@override
void onClose() {
  _reactiveTasksEngine.cancelAll();
  for (final timer in _cleanupTimers.values) {
    timer.cancel();
  }
  _cleanupTimers.clear();
  // Reactive variables are closed by autoDispose
  super.onClose();
}