import { Ref, WatchSource } from "vue"; //#region src/composables/useToggleScope/index.d.ts interface ToggleScopeControls { /** * Whether the scope is currently active (created and running) */ readonly isActive: Readonly>; /** * Stop the scope (destroys and cleans up all effects) */ stop: () => void; /** * Start the scope (creates and runs effects) */ start: () => void; /** * Reset the scope (stops and immediately restarts) */ reset: () => void; } /** * Conditionally manages an effect scope based on a reactive boolean source. * * @param source A reactive boolean value or getter that controls the scope lifecycle * @param fn The function to run within the effect scope. Can optionally receive controls for manual scope management. * @returns Controls object with isActive state and start/stop/reset methods * * @see https://vuejs.org/api/reactivity-advanced.html#effectscope * @see https://0.vuetifyjs.com/composables/system/use-toggle-scope * * @example * ```ts * import { ref } from 'vue' * import { useToggleScope } from '@vuetify/v0' * * const isEnabled = ref(false) * * const { isActive } = useToggleScope(isEnabled, () => { * // This code runs when isEnabled becomes true * const unwatch = watch(someRef, () => { * console.log('Watching...') * }) * * // Cleanup happens automatically when isEnabled becomes false * }) * * // Toggle the scope on/off * isEnabled.value = true // Starts the scope * console.log(isActive.value) // true * isEnabled.value = false // Stops and cleans up * console.log(isActive.value) // false * ``` * * @example * With manual controls: * ```ts * const isEnabled = ref(true) * * useToggleScope(isEnabled, (controls) => { * // Access controls inside the scope * console.log('Active:', controls.isActive.value) * * // Manually reset the scope if needed * someEvent.on('reset', () => controls.reset()) * }) * ``` */ declare function useToggleScope(source: WatchSource, fn: (() => void) | ((controls: ToggleScopeControls) => void)): ToggleScopeControls; //#endregion export { ToggleScopeControls, useToggleScope };