runEffect method
Executes an effect's function while properly tracking dependencies.
This method:
- Saves and updates the currently active subscriber
- Starts dependency tracking for the effect
- Runs the effect's function
- Restores the previous active subscriber
- Ends dependency tracking
effect
The effect to run
Implementation
void runEffect(Effect effect) {
final prevSub = activeSub;
activeSub = effect;
startTracking(effect);
try {
effect.fn();
} finally {
activeSub = prevSub;
endTracking(effect);
}
}