sv-previous Svelte Themes

Sv Previous

A simple Svelte 5 library to track the previous value of a variable using the power of Runes.

SV Previous

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.

Installation

To install the library, you can use one of the following commands:

npm install @trueight/sv-previous
pnpm add @trueight/sv-previous
yarn add @trueight/sv-previous
bun add @trueight/sv-previous

Usage

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.

Features

  • Easy to use, powerful to work with.
  • Tracks the current and previous value of a variable.
  • Allows manual setting of previous values.
  • Supports limits on the number of tracked values.
  • Create a history of previous values that can be accessed and modified.

Contribution

you can contribute to the project in two ways:

  • reporting issues
  • making a pull request

if you want to make a pull request, please make sure to open an issue first to discuss the changes you wish to make.

License

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.

Top categories

Loading Svelte Themes