Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

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);


```