runEffectScope method
Executes a function within an effect scope while tracking dependencies.
This method:
- Saves the current active scope
- Sets the provided scope as active
- Starts dependency tracking for the scope
- Runs the provided function
- Restores the previous active scope
- Ends dependency tracking
scope
The effect scope to run within
fn
The function to execute in the scope
Implementation
void runEffectScope(EffectScope scope, void Function() fn) {
final prevSub = activeScope;
activeScope = scope;
startTracking(scope);
try {
fn();
} finally {
activeScope = prevSub;
endTracking(scope);
}
}