
Security News
curl Shuts Down Bug Bounty Program After Flood of AI Slop Reports
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.
@solid-primitives/timer
Advanced tools
Timer primitives related to setInterval and setTimeout:
makeTimer - Makes an automatically cleaned up timer.createTimer - makeTimer, but with a fully reactive delaycreateTimeoutLoop - Like createInterval, except the delay only updates between executions.createPolled - Polls a function periodically. Returns an to the latest polled value.createIntervalCounter - Creates a counter which increments periodically.npm install @solid-primitives/timer
# or
yarn add @solid-primitives/timer
Makes a timer (setTimeout or setInterval), automatically cleaning up when the current reactive scope is disposed.
const callback = () => {};
const disposeTimeout = makeTimer(callback, 1000, setTimeout);
const disposeInterval = makeTimer(callback, 1000, setInterval);
// ...
dispose(); // clean up manually if needed
makeTimer, but with a fully reactive delay. The delay can also be false, in which case the timer is disabled. Does not return a dispose function.
const callback = () => {};
createTimer(callback, 1000, setTimeout);
createTimer(callback, 1000, setInterval);
// with reactive delay
const callback = () => {};
const [paused, setPaused] = createSignal(false);
const [delay, setDelay] = createSignal(1000);
createTimer(callback, () => !paused() && delay(), setTimeout);
createTimer(callback, () => !paused() && delay(), setInterval);
// ...
setDelay(500);
// pause
setPaused(true);
// unpause
setPaused(false);
Similar to an interval created with createTimer, but the delay does not update until the callback is executed.
const callback = () => {};
createTimeoutLoop(callback, 1000);
// with reactive delay
const callback = () => {};
const [delay, setDelay] = createSignal(1000);
createTimeoutLoop(callback, delay);
// ...
setDelay(500);
Periodically polls a function, returning an accessor to its last return value.
const date = createPolled(() => new Date(), 1000);
// ...
<span>The time is: {date()}</span>;
// with reactive delay
const [delay, setDelay] = createSignal(1000);
createPolled(() => new Date(), delay);
// ...
setDelay(500);
A counter which increments periodically based on the delay.
const count = createIntervalCounter(1000);
// ...
<span>Count: {count()}</span>;
// with reactive delay
const [delay, setDelay] = createSignal(1000);
createIntervalCounter(delay);
// ...
setDelay(500);
When a delay is changed, the fraction of the existing delay already elapsed be carried forward to the new delay. For instance, a delay of 1000ms changed to 2000ms after 250ms will be considered 1/4 done, and next callback will be executed after 250ms + 1500ms. Afterwards, the new delay will be used.
You may view a working example here: https://codesandbox.io/s/solid-primitives-timer-6n7dt?file=/src/index.tsx
0.0.100
First commit of the timer primitive.
0.0.107
Patched an issue with clear on clean-up.
1.0.3
Release official version with CJS support.
1.1.0
Updated to Solid 1.3
1.3.0
Added makeTimer, createTimeoutLoop, createPolled, createIntervalCounter, and made the timeout of createTimer optionally reactive.
1.3.1
Make the calc function of createPolled reactive
FAQs
Primitives to manage timeout and interval
The npm package @solid-primitives/timer receives a total of 23,447 weekly downloads. As such, @solid-primitives/timer popularity was classified as popular.
We found that @solid-primitives/timer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.

Product
Scan results now load faster and remain consistent over time, with stable URLs and on-demand rescans for fresh security data.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.