EffectImpl class
Implementation of Effect that automatically runs when its dependencies change.
This is the concrete implementation of the Effect interface. 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.
See Effect for the public interface and usage examples.
Example:
final count = Signal(0);
// Effect runs immediately and whenever count changes
final effect = Effect(() {
print('Count is: ${count.value}');
});
count.value = 1; // Prints: "Count is: 1"
count.value = 2; // Prints: "Count is: 2"
effect.dispose(); // Stop the effect
- Inheritance
-
- Object
- ReactiveNode
- EffectReactiveNode
- EffectImpl
- Implemented types
- Mixed-in types
Constructors
- EffectImpl(void fn(), {bool lazy = false, JoltDebugFn? onDebug})
- Creates a new effect with the given function.
- EffectImpl.lazy(void fn(), {JoltDebugFn? onDebug})
-
Creates a new effect that runs immediately upon creation.
factory
Properties
- deps ↔ Link?
-
First dependency link in the chain.
getter/setter pairinherited
- depsTail ↔ Link?
-
Last dependency link in the chain.
getter/setter pairinherited
- flags ↔ int
-
Reactive flags for this node.
getter/setter pairinherited
- fn → void Function()
-
The function that defines the effect's behavior.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- subs ↔ Link?
-
First subscriber link in the chain.
getter/setter pairinherited
- subsTail ↔ Link?
-
Last subscriber link in the chain.
getter/setter pairinherited
Methods
-
dispose(
) → void -
Disposes this node and cleans up resources.
inherited
-
doCleanup(
) → void -
Executes all registered cleanup functions and clears the cleanup list.
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 this effect is disposed or re-run.
inherited
-
onDispose(
) → void -
Called during the disposal process to perform custom cleanup.
override
-
run(
) → void -
Manually runs the effect function.
override
-
runEffect(
) → void -
Executes the effect when it is dirty or pending.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
wrappedFn(
) → void
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited