Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/its-just-nans/supercharged-store
svelte-store but in VanillaJS
https://github.com/its-just-nans/supercharged-store
reactive store svelte vanilla-js
Last synced: 28 days ago
JSON representation
svelte-store but in VanillaJS
- Host: GitHub
- URL: https://github.com/its-just-nans/supercharged-store
- Owner: Its-Just-Nans
- License: mit
- Created: 2022-06-22T10:27:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-22T14:25:43.000Z (over 2 years ago)
- Last Synced: 2024-08-18T21:49:10.617Z (4 months ago)
- Topics: reactive, store, svelte, vanilla-js
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# supercharged-store · [![npm version](https://img.shields.io/npm/v/supercharged-store.svg)](https://www.npmjs.org/package/supercharged-store)
`svelte-store` in VanillaJS
## Usage
- Real examples in `/example`
### Create a store
```js
import { makeStore } from "../index.js";export const myStore = makeStore({ foo: "bar" });
```### Subscribe to a store
```js
import { myStore } from "./actualStores.js";myStore.subscribe((currentNewValue) => {
console.log("new value in", currentNewValue);
});
```### Set new value
```js
import { myStore } from "./actualStores.js";myStore.set("New Value");
```### Update the value (using the previous value)
```js
import { myStore } from "./actualStores.js";myStore.update((oldValue) => {
return oldValue.toString() + "updated";
});
```## License
Licensed under the MIT License - [LICENSE](LICENSE)