gjendje 0.9.2 → 0.9.3
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 +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,23 +25,23 @@ const theme = state.local({ theme: 'light' })
|
|
|
25
25
|
For in-memory state that doesn't persist, use `state` without a scope:
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
|
-
const
|
|
28
|
+
const user = state({ name: 'John', age: 30 })
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
### Getting values
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
|
-
|
|
35
|
-
const {
|
|
34
|
+
user.get() // { name: 'John', age: 30 }
|
|
35
|
+
const { name } = user.get() // Destructure specific values
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
### Updating values
|
|
39
39
|
|
|
40
|
-
Replace the entire
|
|
40
|
+
Replace the entire state with `set`, or use an updater function:
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
user.set({ name: 'Jane', age: 25 })
|
|
44
|
+
user.set((prev) => ({ ...prev, age: prev.age + 1 }))
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
For object stores, `patch` lets you update specific properties without spreading:
|