-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5f96aa
commit 541efcb
Showing
7 changed files
with
1,155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
### Node template | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,65 @@ | ||
# solid-periodic-signal | ||
|
||
The **Periodic Signal Creator** is a utility function for creating periodic signals that can be started and stopped. This utility is useful in scenarios where you need to perform periodic tasks, such as updating data or triggering actions at specified intervals. | ||
|
||
## Motivation | ||
|
||
In many applications, there's a need to execute certain functions or tasks at regular intervals. For example, you might want to periodically update data from a remote server, check for new messages, or refresh a user interface. To achieve this, you can use JavaScript's `setInterval` function. However, managing and controlling these periodic tasks can become complex as your application grows. The **Periodic Signal Creator** simplifies this by providing an easy-to-use interface for starting and stopping periodic tasks. | ||
|
||
## Usage | ||
|
||
## Usage | ||
|
||
The `createPeriodicSignal` function creates a periodic signal that can be started and stopped. It takes the following parameters: | ||
|
||
- `updateFunction`: A callback function that will be called periodically. | ||
- `periodInterval` (optional, default: 1): The interval (in seconds or milliseconds, depending on the `inMs` parameter) between each `updateFunction` call. | ||
- `inMs` (optional, default: false): If true, the `periodInterval` is in milliseconds; otherwise, it is in seconds. | ||
|
||
The function returns an array containing two functions: | ||
|
||
- `startSignal`: A function that can be used to start the periodic signal. | ||
- `stopSignal`: A function that can be used to stop the periodic signal. | ||
|
||
|
||
```tsx | ||
import { createPeriodicSignal } from 'periodic-signal-creator'; | ||
|
||
function App() { | ||
const [count, setCount] = createSignal(0); | ||
const [startCounting, stopCounting] = createPeriodicSignal(() => { | ||
setCount((prev) => prev + 1); | ||
}); | ||
startCounting(); | ||
|
||
return ( | ||
<> | ||
<div> | ||
<a href="https://vitejs.dev" target="_blank"> | ||
<img src={viteLogo} class="logo" alt="Vite logo" /> | ||
</a> | ||
<a href="https://solidjs.com" target="_blank"> | ||
<img src={solidLogo} class="logo solid" alt="Solid logo" /> | ||
</a> | ||
</div> | ||
<h1>Vite + Solid</h1> | ||
<div class="card"> | ||
<button onClick={stopCounting()}> | ||
|
||
count is {count()} | ||
</button> | ||
|
||
<p> | ||
Edit <code>src/App.tsx</code> and save to test HMR | ||
</p> | ||
</div> | ||
<p class="read-the-docs"> | ||
Click on the Vite and Solid logos to learn more | ||
</p> | ||
</> | ||
) | ||
} | ||
|
||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "solid-periodic-signal", | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/index.mjs", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "tsup src/index.ts --format cjs,esm --dts" | ||
}, | ||
"dependencies": { | ||
"solid-js": "^1.7.11", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
Oops, something went wrong.