EffectScopeImpl constructor
EffectScopeImpl({
- bool? detach,
- JoltDebugOption? debug,
Creates a new effect scope.
Parameters:
detach: Whether to detach this scope from its parent scope. If true, the scope will not be automatically disposed when its parent is disposed. Defaults to false.debug: Optional debug options
The scope is automatically linked to its parent scope (if any) unless
detach is true. Use run to execute code within the scope context.
Example:
final scope = EffectScope()
..run(() {
final signal = Signal(0);
Effect(() => print(signal.value));
// Register cleanup function
onScopeDispose(() => print('Scope disposed'));
});
Implementation
EffectScopeImpl({bool? detach, JoltDebugOption? debug})
: super(flags: ReactiveFlags.none) {
JoltDebug.create(this, debug);
if (!(detach ?? false)) {
final prevSub = getActiveSub();
if (prevSub != null) {
link(this, prevSub, 0);
}
}
}