(
timeout = 400,
)
| 168 | * Creates a signal that will be activated for a given amount of time on every "ping" — a call to the listener function. |
| 169 | */ |
| 170 | export function createPingedSignal( |
| 171 | timeout = 400, |
| 172 | ): [isUpdated: Accessor<boolean>, ping: VoidFunction] { |
| 173 | const [isUpdated, setIsUpdated] = createSignal(false) |
| 174 | |
| 175 | let timeoutId: ReturnType<typeof setTimeout> | undefined |
| 176 | const ping = (): void => { |
| 177 | setIsUpdated(true) |
| 178 | clearTimeout(timeoutId) |
| 179 | timeoutId = setTimeout(() => setIsUpdated(false), timeout) |
| 180 | } |
| 181 | onCleanup(() => clearTimeout(timeoutId)) |
| 182 | |
| 183 | return [isUpdated, ping] |
| 184 | } |
no test coverage detected
searching dependent graphs…