@shared-state/core
Version:
The core package of `@shared-state`
32 lines (19 loc) • 571 B
Markdown
# -state/core
The core package of `-state`
## Quick Start
Install `-state/core`
```
pnpm install -state/core
```
## Example
### Basic
```js
import { createSharedState } from "@shared-state/core";
const CountState = createSharedState(0);
CountState.get(); // Get value
CountState.set((count) => count + 1); // Set value
const onSharedStateChange = ({ previousState, nextState }) =>
console.log(previousState, nextState)
CountState.subscribe(onSharedStateChange); // Subscribe state
CountState.unsubscribe(onSharedStateChange)
```