https://github.com/dev-siri/reactivity-stores
Simple TypeScript-first state management with reactive stores.
https://github.com/dev-siri/reactivity-stores
Last synced: about 1 year ago
JSON representation
Simple TypeScript-first state management with reactive stores.
- Host: GitHub
- URL: https://github.com/dev-siri/reactivity-stores
- Owner: Dev-Siri
- License: other
- Created: 2023-08-10T18:37:28.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-12T08:57:47.000Z (almost 3 years ago)
- Last Synced: 2024-10-11T00:33:04.460Z (over 1 year ago)
- Language: TypeScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Reactive Stores
Reactive is a powerful tool for managing application state in a reactive and efficient manner. It provides a clean and organized way to handle global state, reactivity, and state updates.
## Installation
You can install the library using your preferred package manager:
```bash
pnpm add reactive-stores
```
## Usage
Import the library and start using it to manage your application's state. Here's a simple example of how you might use the library:
```ts
// Type modules for end-to-end type safety
import Store, { mergeStores, type State } from "reactive-stores";
// Create stores
const counterStore = new Store("counter-store", { count: 0 });
const inputStore = new Store("input-store", {
email: "hello@example.com",
password: "********",
});
// Merge stores
const mergedStore = mergeStores<{
"counter-store": State;
"input-store": State;
}>("merged-store", [counterStore, inputStore]);
// Subscribe to stores
const currentCount = counterStore.subscribe((count) =>
console.log("Current count:", count)
);
// and update it
counterStore.set({ count: (prevCount) => ++prevCount });
```
## Features
- **Global State Management:** Manage global application state that can be accessed and updated from different components.
- **Reactivity:** Automatically update components when the state changes, reducing manual handling and improving consistency.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.