@storve/core 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -4
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -124,7 +124,7 @@ Storve uses subpath imports so you only bundle what you use:
|
|
|
124
124
|
|
|
125
125
|
| Import | Size (gzipped) | Use when |
|
|
126
126
|
|--------|----------------|----------|
|
|
127
|
-
| `import { createStore, batch } from '@storve/core'` | ~1.4 KB | Core store
|
|
127
|
+
| `import { createStore, batch, compose } from '@storve/core'` | ~1.4 KB | Core store, enhancer composition |
|
|
128
128
|
| `import { createAsync } from '@storve/core/async'` | +1.1 KB | Async state, fetching, caching |
|
|
129
129
|
| `import { computed } from '@storve/core/computed'` | +0.8 KB | Derived state |
|
|
130
130
|
| `import { withPersist } from '@storve/core/persist'` | +1.2 KB | Persistence, adapters |
|
|
@@ -622,12 +622,33 @@ import { createStore } from '@storve/core'
|
|
|
622
622
|
import { withPersist } from '@storve/core/persist'
|
|
623
623
|
import { localStorageAdapter } from '@storve/core/persist/adapters/localStorage'
|
|
624
624
|
|
|
625
|
-
const store = withPersist({
|
|
626
|
-
key: 'app',
|
|
627
|
-
adapter: localStorageAdapter()
|
|
625
|
+
const store = withPersist({
|
|
626
|
+
key: 'app',
|
|
627
|
+
adapter: localStorageAdapter()
|
|
628
628
|
})(createStore({ count: 0 }))
|
|
629
629
|
```
|
|
630
630
|
|
|
631
|
+
### `compose(store, ...enhancers)`
|
|
632
|
+
|
|
633
|
+
Pipes a store through one or more enhancer functions left-to-right. Use it when combining multiple enhancers (persist + devtools + sync) in a single store.
|
|
634
|
+
|
|
635
|
+
```ts
|
|
636
|
+
import { createStore, compose } from '@storve/core'
|
|
637
|
+
import { withPersist } from '@storve/core/persist'
|
|
638
|
+
import { localStorageAdapter } from '@storve/core/persist/adapters/localStorage'
|
|
639
|
+
import { withDevtools } from '@storve/core/devtools'
|
|
640
|
+
import { withSync } from '@storve/core/sync'
|
|
641
|
+
|
|
642
|
+
const store = compose(
|
|
643
|
+
createStore({ count: 0, theme: 'light' }),
|
|
644
|
+
s => withPersist(s, { key: 'app', adapter: localStorageAdapter() }),
|
|
645
|
+
s => withDevtools(s, { name: 'My Store' }),
|
|
646
|
+
s => withSync(s, { channel: 'my-app', keys: ['theme'] })
|
|
647
|
+
)
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
Enhancers are applied left-to-right: the output of each becomes the input of the next. With no enhancers, `compose(store)` returns the store unchanged.
|
|
651
|
+
|
|
631
652
|
---
|
|
632
653
|
|
|
633
654
|
## Signals (v0.5)
|