RtHook class abstract

An abstract-class that provides the functionality of RtState.

This is an example of how to create a custom hook:

class UseToggle extends RtHook {
  final $ = RtHook.$register;
  final _state = UseState(false);

  bool get value => _state.value;

  UseToggle(bool initial) {
    _state.value = initial;
  }

  void toggle() => _state.value = !_state.value;
}

RECOMMENDED: All RtHook must be registered using the final $ variable.:

and use it, like so:

class AppController {
  final uToggle = UseToggle(false);

  UserContext() {
    print('initial value: ${uToggle.value}');

    uToggle.toggle();

    print('toggle value: ${uToggle.value}');
  }
}

See also:

Mixed-in types

Constructors

RtHook.new()

Properties

$ → HookBindingZone<IHook>
This variable is used to register IHook and attach the IState that are defined here.
no setterinherited
boundInstance Object?
The reference instance to the current state.
no setterinherited
debugInfo Map<String, dynamic>
A map containing information about state for debugging purposes.
no setterinherited
debugLabel String?
A label used for debugging purposes.
no setterinherited
dependencyInjection → DependencyInjection
no setterinherited
eventHandler → EventHandler
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isDisposed bool
Returns true if the state has been disposed.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stateManagement → StateManagement<IState>
no setterinherited

Methods

bind(Object instance) → void
Stores a reference to an object instance
inherited
dispose() → void
Called when this object is removed
inherited
initHook() → void
Initializes the hook. This method is called when the hook is created. You can override this method to ensure that the hook is properly initialized and to bind the instance to the states. This is particularly useful for setting up state dependencies or performing side effects when the hook is first created.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
It's used to notify listeners that the state has been updated. It is typically called after making changes to the state object.
inherited
toString() String
A string representation of this object.
inherited
unbind() → void
Removes the reference to the object instance
inherited
update([covariant dynamic fnUpdate()?]) → void
Executes fnUpdate, and notify the listeners about to update.

Operators

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

Static Properties

$register → dynamic
This getter allows access to the HookBindingZone instance which is responsible for registering a RtHook and attaching previously collected states to it.
no setter