Effect class
An Effect represents a side-effect function that automatically re-runs whenever any of the signals or computed values it accesses during execution change.
Constructors
- Effect(void _fn()?)
- Creates a new Effect and executes the given function immediately.
- Effect.lazy(void _fn()?)
- Creates a new Effect without executing the callback function immediately.
- Effect.withCleanup(void fn(void (void ())))
- Creates an effect that can register cleanup callbacks for each run.
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
-
addDependency(
Node node) → void - Registers a node as a dependency.
-
clearDependencies(
) → void - Clears all existing registered dependencies and unsubscribes from them.
-
dispose(
) → void - Disposes of the effect, clearing all dependencies and preventing further execution.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notify(
) → void - Called when any of the observed dependencies changes.
-
run(
) → void - Runs the effect function, tracking any signals or computeds read during execution.
-
toString(
) → String -
A string representation of this object.
inherited
-
track<
R> (R fn()) → R -
Executes the given function
fnwithin this effect's tracking context.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited