Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aredridel/svelte-damped-store
A derived writable store that can suspend updates
https://github.com/aredridel/svelte-damped-store
Last synced: about 1 month ago
JSON representation
A derived writable store that can suspend updates
- Host: GitHub
- URL: https://github.com/aredridel/svelte-damped-store
- Owner: aredridel
- Created: 2022-05-15T19:22:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-15T19:28:37.000Z (over 2 years ago)
- Last Synced: 2024-10-17T19:03:19.626Z (about 2 months ago)
- Language: TypeScript
- Size: 13.7 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-svelte-stores - svelte-damped-store
README
# Svelte Damped Store
This module came about because I was binding an `` to a numeric store, which would update and reflect the most recent server value back, while user input was ongoing. This gives a tidy interface to suspend updates while a user is interacting (at least with the mouse for now), and resume when they let go and a little time has passed.
## Use
```svelte
import { damped, dampedAction } from "@aredridel/svelte-damped-store";
import { writable } from "svelte/store";const base = writable(0);
// Simulate server roundtripping
base.subscribe(val => {
setTimeout(() => {
writable.set(val);
}, 80);
});const store = damped(base);
```