1.0.0 • Published 2 years ago

supercharged-store v1.0.0

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

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