@gluonjs/reactivity / packages/reactivity/src / EffectScopeOptions
Interface: EffectScopeOptions
Properties
detached?
readonlyoptionaldetached?:boolean
onError?
readonlyoptionalonError?:ReactivityErrorHandler
Example
Choose whether a scope is detached from its active parent and how errors from its owned resources are handled:
import {
EffectScope,
effect,
effectScope,
getCurrentScope,
onScopeDispose,
ref,
type EffectScopeOptions,
} from '@gluonjs/reactivity';
const options: EffectScopeOptions = {
detached: true,
onError: ({ error }) => console.error(error),
};
const scope: EffectScope = effectScope(options);
const count = ref(0);
scope.run(() => {
console.log(getCurrentScope() === scope);
effect(() => console.log(count.value));
onScopeDispose(() => console.log('scope disposed'));
});
count.value = 1;
scope.stop();