sustand
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

sustand

npm (tag) npm bundle size NPM

State-management solution for Svelte using simplified flux principles. Powered by zustand. Implements the store contract.

Installation

npm install sustand

Usage

First create a store

import create from 'sustand'

const useStore = create(set => ({
  bears: 0,
  increase: () => set(state => ({ bears: state.bears + 1 })),
}))

Then bind your components, and that's it!

<script>
  import { useStore } from '$lib/store'
  const bears = useStore((state) => state.bears)
</script>

<h1>{$bears} around here ...</h1>
<script>
  import { useStore } from '$lib/store'
  const increase = useStore((state) => state.increase)
</script>

<button on:click="() => $increase()">one up</button>

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i sustand

Weekly Downloads

50

Version

0.0.2

License

MIT

Unpacked Size

7.81 kB

Total Files

6

Last publish

Collaborators

  • wobsoriano