supercharged-store Svelte Themes

Supercharged Store

svelte-store but in VanillaJS

supercharged-store ·

svelte-store in VanillaJS

Usage

  • Real examples in /example

Create a store

import { makeStore } from "../index.js";

export const myStore = makeStore({ foo: "bar" });

Subscribe to a store

import { myStore } from "./actualStores.js";

myStore.subscribe((currentNewValue) => {
    console.log("new value in", currentNewValue);
});

Set new value

import { myStore } from "./actualStores.js";

myStore.set("New Value");

Update the value (using the previous value)

import { myStore } from "./actualStores.js";

myStore.update((oldValue) => {
    return oldValue.toString() + "updated";
});

License

Licensed under the MIT License - LICENSE

Top categories

Loading Svelte Themes