Effect class abstract

Interface for reactive effects that run when dependencies change.

Effects are side-effect functions that run in response to reactive state changes. They automatically track their dependencies and re-run when any dependency changes.

Nested effects created inside an effect are not automatically disposed when the parent effect is disposed. The caller is responsible for managing the lifecycle of nested effects.

Example:

Effect effect = Effect(() {
  print('Count: ${count.value}');
});
effect.run(); // Manually trigger
effect.dispose(); // Stop the effect
Implemented types

Constructors

Effect(void fn(), {bool lazy, bool? detach, JoltDebugOption? debug})
Creates a new effect with the given function.
factory
Effect.lazy(void fn(), {bool? detach, JoltDebugOption? debug})
Creates a new effect that does not run automatically upon creation.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isDisposed bool
Whether this node has been disposed.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Disposes this node and cleans up resources.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onCleanUp(Disposer fn) → void
Registers a cleanup function to be called when the effect is disposed or re-run.
run() → void
Manually runs the effect function.
toString() String
A string representation of this object.
inherited

Operators

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