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

0.0.5 • Public • Published

sveltix

Better way to manage your complex stores in Svelte.

Why?

Even though Svelte has a great store system it is very hard to work with complex data with it. Sveltix solves this issue by providing a flexible API like Pinia which is integrated with Svelte stores, automaticly giving you the flexibility out of the box.

Usage

Basic usage

<script>
  import { sveltix } from "sveltix";

  const newStore = sveltix({
    state: () => ({
     value: 1
    })
  });

  const useStore = newStore.useStore();
</script>

<button
  on:click={() => newStore.value++}>count is {$useStore.value}
</button>

Custom functions

<script>
  import { sveltix } from "sveltix";

  const newStore = sveltix({
    state: () => ({
      value: 1,
    }),
    actions: {
      increment() {
        this.value++;
      },
    },
  });

  const useStore = newStore.useStore();
</script>

<button on:click={() => newStore.increment()}>count is {$useStore.value}</button>

Note

I'm currently working on implementing getters and better type declarations. Pull requests are also open 😅

Package Sidebar

Install

npm i sveltix

Weekly Downloads

3

Version

0.0.5

License

MIT

Unpacked Size

5.81 kB

Total Files

7

Last publish

Collaborators

  • spongebed