FeatureObserver<State, Msg, Effect> class
abstract
A base class for observing feature lifecycle events and interactions.
FeatureObserver provides hooks to monitor a feature's lifecycle, state changes, messages, and effects. This is useful for debugging, logging, or analytics.
Hooks:
- onCreate: Called when the feature is created. Provides the feature instance.
- onInit: Called when the feature is initialized.
- onDispose: Called when the feature is disposed.
- onState: Called when the feature's state changes.
- onMsg: Called when a message is accepted by the feature.
- onEffect: Called when an effect is emitted by the feature.
Usage:
Extend this class and override the hooks you need. Attach the observer using the observe extension.
Example:
class MyObserver extends FeatureObserver<MyState, MyMsg, MyEffect> {
@override
void onState(MyState state) {
print('State changed: $state');
}
@override
void onMsg(MyMsg message) {
print('Message received: $message');
}
}
- Annotations
-
- @experimental
Constructors
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCreate(
) → void - Called when the feature is created.
-
onDispose(
) → void - Called when the feature is disposed.
-
onEffect(
Effect effect) → void - Called when an effect is emitted by the feature.
-
onInit(
) → void - Called when the feature is initialized.
-
onMsg(
Msg message) → void - Called when a message is accepted by the feature.
-
onState(
State state) → void - Called when the feature's state changes.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited