Spaces:
Sleeping
Sleeping
Download frontend/node_modules/@mui/utils/esm/useTimeout/useTimeout.js from sepidnes/pythonic-rag-FastAPIReact: direct link, hf CLI and curl.
- Browser
- Download file 826 Bytes
-
https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/%40mui/utils/esm/useTimeout/useTimeout.js
- Command line
-
hf download hf://spaces/sepidnes/pythonic-rag-FastAPIReact@c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/@mui/utils/esm/useTimeout/useTimeout.js
-
curl -L -o useTimeout.js https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/%40mui/utils/esm/useTimeout/useTimeout.js
826 Bytes
| 'use client'; | |
| import useLazyRef from '../useLazyRef/useLazyRef'; | |
| import useOnMount from '../useOnMount/useOnMount'; | |
| export class Timeout { | |
| constructor() { | |
| this.currentId = null; | |
| this.clear = () => { | |
| if (this.currentId !== null) { | |
| clearTimeout(this.currentId); | |
| this.currentId = null; | |
| } | |
| }; | |
| this.disposeEffect = () => { | |
| return this.clear; | |
| }; | |
| } | |
| static create() { | |
| return new Timeout(); | |
| } | |
| /** | |
| * Executes `fn` after `delay`, clearing any previously scheduled call. | |
| */ | |
| start(delay, fn) { | |
| this.clear(); | |
| this.currentId = setTimeout(() => { | |
| this.currentId = null; | |
| fn(); | |
| }, delay); | |
| } | |
| } | |
| export default function useTimeout() { | |
| const timeout = useLazyRef(Timeout.create).current; | |
| useOnMount(timeout.disposeEffect); | |
| return timeout; | |
| } |