SuperController class mixin

A mixin class that provides a lifecycle for controllers used in the application.

The SuperController mixin class allows you to define the lifecycle of your controller classes. It provides methods that are called at specific points allowing you to initialize resources, handle events, and clean up resources when the controller is no longer needed.

Example usage:

class CounterController extends SuperController {
  final _count = 0.rx; // RxInt(0);

  int get count => _count.state;

  void increment() {
    _count.state++;
  }

  @override
  void onDisable() {
    _count.dispose(); // Dispose Rx object.
    super.onDisable();
  }
}

In the example above, CounterController extends SuperController and defines a count variable that is managed by an Rx object. The increment() method is used to increment the count state. The onDisable() method is overridden to dispose of the Rx object when the controller is disabled.

Note: It is recommended to define Rx objects as private and only provide a getter for accessing the state. This helps prevent the state from being changed outside of the controller, ensuring that the state is only modified through defined methods within the controller (e.g., increment() in the example).

Constructors

SuperController.new()
SuperController Constructor

Properties

alive bool
Checks whether the controller is alive.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

disable() → void
This method is called when the controller is removed from memory. It marks the controller as disabled and calls the onDisable method.
enable() → void
This method is called first time the controller is accessed or utilized. It defines the lifecycle of the subclass and should not be overridden.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAlive() → void
Called one frame after the onEnable method.
onDisable() → void
This method can be used to dispose of resources used by the controller.
onEnable() → void
This method is called when the controller is accessed for the first time, which typically happens when the controller is allocated in memory.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited