tryOnScopeDispose
Register teardown with the currently-active scope — the owning component's setup, or the innermost running effectScope(). Cross-platform — import from @sigx/use.
import { tryOnScopeDispose } from '@sigx/use';
const id = setInterval(tick, 1000);
tryOnScopeDispose(() => clearInterval(id));
It returns false (retaining nothing) when called outside any scope — the caller keeps responsibility for disposal then. That's exactly why every composable with ongoing work also returns an explicit stop()/Pausable handle: it's the escape hatch for standalone, scope-less use.
const registered = tryOnScopeDispose(cleanup);
if (!registered) {
// no active scope — you must call cleanup() yourself
}
Signature
function tryOnScopeDispose(fn: () => void): boolean;
Returns true when the teardown was registered with a scope, false when there was no active scope.
Platform: everywhere.
See also
tryOnMounted— the mount-time counterpart.- Conventions → Lifecycle helpers — how these two power the cleanup model.
- Conventions → Control handles — the
stop()/Pausablehandles that back scope-less use.
