0.0.2 • Published 2 years ago

sustand v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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