ReactterHook class abstract

An abstract-class to provides the functionality of ReactterHookManager and is added as a dependency of another ReactterHookManager behaving as a state.

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
Mixed in types
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

dispose() → void
Called when this object is removed
inherited
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
refresh() → void
Forces update and notifies to listeners that it did update
inherited
toString() String
A string representation of this object.
inherited
update([covariant Function? callback]) → void
Executes fnUpdate, and notify the listeners about to update.
override
updateAsync([covariant Function? callback]) Future<void>
Executes fnUpdate, and notify the listeners about to update as async way.
override

Operators

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