svelte-store but in VanillaJS
| example | feat: add docs && example | |
| .gitignore | [feature] push | |
| .npmignore | fix: add files | |
| index.js | feat: add docs && example | |
| index.ts | [feature] push | |
| LICENSE | Initial commit | |
| package-lock.json | fix: change name | |
| package.json | fix: change name | |
| README.md | fix: push | |
supercharged-store · npm version
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