MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / createPingedSignal

Function createPingedSignal

packages/shared/src/primitives.ts:170–184  ·  view source on GitHub ↗
(
    timeout = 400,
)

Source from the content-addressed store, hash-verified

168 * Creates a signal that will be activated for a given amount of time on every "ping" — a call to the listener function.
169 */
170export 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}

Callers 2

ValueNodeFunction · 0.90

Calls 1

onCleanupFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…