Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)