Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MacFJA/svelte-expirable
A Svelte store with items that expire
https://github.com/MacFJA/svelte-expirable
Last synced: 28 days ago
JSON representation
A Svelte store with items that expire
- Host: GitHub
- URL: https://github.com/MacFJA/svelte-expirable
- Owner: MacFJA
- License: mit
- Created: 2021-12-02T21:43:19.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-03T20:12:10.000Z (about 3 years ago)
- Last Synced: 2024-11-14T02:37:44.073Z (29 days ago)
- Language: TypeScript
- Size: 16.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-svelte-stores - @macfja/svelte-expirable
README
# Svelte Expirable store
A Svelte store with items that expire
## Installation
```
npm install @macfja/svelte-expirable
```## Usage
`notification.js`
```javascript
import { expirable } from "@macfja/svelte-expirable"export const notifications = expirable()
````App.svelte`
```htmlimport { notifications } from './notifications.js'
const onClickHandler = () => {
// Do some action
notifications.push('Data saved', 2) // Message expire after 2 seconds
}{#each $notifications as {data, id, repeated} (id)}
{/each}```
When the same data is push to the store, the expiration time is reset to the new TTL, and the `repeated` variable is incremented
## Contributing
Contributions are welcome. Please open up an issue or create PR if you would like to help out.
Read more in the [Contributing file](CONTRIBUTING.md)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.