import { onMounted , onUnmounted , ref , Ref } from '@src/api' ; export function useIntervalFn ( callback , ms = 0 , runOnMount = true ) { const isRunning = ref ( false ) ; let interval = null ; const start = ( ) => { if ( interval ) return ; isRunning . value = true ; interval = setInterval ( callback , ms ) ; } ; const stop = ( ) => { clearInterval ( interval ) ; isRunning . value = false ; interval = null ; } ; onMounted ( ( ) => runOnMount && start ( ) ) ; onUnmounted ( stop ) ; return { isRunning , start , stop } ; }