A simple Svelte 5 library to track the previous value of a variable using the power of Runes.
you can see a simple demo at SV Previous website, or test it in the Svelte Playground.
a storybook is also available at Storybook SV Previous.
npm install @trueight/sv-previous
pnpm add @trueight/sv-previous
yarn add @trueight/sv-previous
bun add @trueight/sv-previous
Here is an minimal example of how to use the Previous
library:
<script lang="ts">
import { Previous } from '@trueight/sv-previous'
let value = $state('')
const previous = new Previous(() => value)
</script>
<div>
<p>{previous.previous}</p>
<p>{previous.current}</p>
<input bind:value={value} />
</div>
see it in the Svelte Playground.
you can contribute to the project in two ways:
if you want to make a pull request, please make sure to open an issue first to discuss the changes you wish to make.
This project is licensed under the MIT License - see the LICENSE file for details and feel free to make anything you want with this code.