ReactterHook class abstract

An abstract-class that provides the functionality of ReactterState.

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

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

  bool get value => _state.value;

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

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

IMPORTANT: All ReactterHook must be registered using the final $ variable.:

and use it, like so:

class AppController {
  final state = UseToggle(false);

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

    state.toggle();

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

See also:

Implemented types
Implementers

Constructors

ReactterHook()

Properties

$ → HookRegister
This variable is used to register Hook and attach the StateBase that are defined here.
no setterinherited
eventManager → EventManager
no setter
hashCode int
The hash code for this object.
no setterinherited
instanceBinded Object?
The reference instance to the current state.
no setterinherited
instanceManager → InstanceManager
no setter
isDisposed bool
Returns true if the state has been disposed.
no setterinherited
logger → Logger
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stateManager → StateManager<StateBase>
no setter

Methods

bind(Object instance) → void
Stores a reference to an object instance
inherited
dispose() → void
Called when this object is removed
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refresh() → 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 Function? callback]) → void
Executes callback, and notifies the listeners about the update.
inherited

Operators

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

Static Properties

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