19 lines
		
	
	
		
			441 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			441 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import { tryOnScopeDispose } from '@vueuse/core';
 | |
| 
 | |
| function useTimeout() {
 | |
|   let timeoutHandle;
 | |
|   const registerTimeout = (fn, delay) => {
 | |
|     cancelTimeout();
 | |
|     timeoutHandle = window.setTimeout(fn, delay);
 | |
|   };
 | |
|   const cancelTimeout = () => window.clearTimeout(timeoutHandle);
 | |
|   tryOnScopeDispose(() => cancelTimeout());
 | |
|   return {
 | |
|     registerTimeout,
 | |
|     cancelTimeout
 | |
|   };
 | |
| }
 | |
| 
 | |
| export { useTimeout };
 | |
| //# sourceMappingURL=index.mjs.map
 |