supercharged-store

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i supercharged-store

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

4.59 kB

Total Files

5

Last publish

Collaborators

  • n4n5