ReactterHook class abstract

Provides the functionality of ReactterHookManager.

Depends on a ReactterHookManager to listen this hook

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

class UseToggle extends ReactterHook {
  late final _state = UseState(false, this);

  bool get value => _state.value;

  UseToggle(
    bool initial,
    [ReactterContext? context],
  ): super(context) {
    _state.value = initial;
  }

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

and use it like this:

class AppContext extends ReactterContext {
  late final state = UseToggle(false, this);

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

    state.toggle();

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

See also:

Inheritance
Implementers

Constructors

ReactterHook(ReactterHookManager? context)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

listenHooks(List<ReactterHook> hooks) → void
Suscribes to all hooks given.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
update([Function? callback]) → void
First, invokes the subscribers callbacks of the willUpdate event.

Operators

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