Skip to content

Commit b7a9c9d

Browse files
committed
update docs for accuracy
1 parent 1e410e6 commit b7a9c9d

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/routes/reference/store-utilities/create-mutable.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Mutable store proxy.
5656

5757
- `createMutable` creates mutable shared state through a reactive proxy. Property reads and writes go through that proxy, and nested property access is reactive.
5858
- Writes, deletes, and array mutator methods are batched through the proxy while updating the store in place.
59-
- This is primarily a client-side reactive proxy mechanism.
59+
- `createMutable` exposes reads and writes through the same proxy instead of separating them into a getter and setter.
6060
- Getters and setters defined on the initial object remain available on the mutable store.
6161

6262
## Examples
@@ -86,10 +86,12 @@ const user = createMutable({
8686
get fullName() {
8787
return `${this.firstName} ${this.lastName}`;
8888
},
89-
set setFullName(value) {
89+
set fullName(value) {
9090
[this.firstName, this.lastName] = value.split(" ");
9191
},
9292
});
93+
94+
user.fullName = "Jane Doe";
9395
```
9496

9597
## Related

src/routes/reference/store-utilities/create-store.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Store<T> = T;
2727

2828
interface SetStoreFunction<T> {
2929
(setter: T | Partial<T> | ((prev: T) => T | Partial<T>)): void;
30+
(...path: unknown[]): void;
3031
}
3132

3233
function createStore<T extends object = {}>(
@@ -59,9 +60,9 @@ Tuple containing the store proxy and its setter.
5960

6061
## Behavior
6162

62-
- The returned store is read through a proxy.
63-
- The setter can replace the whole store or update nested paths.
64-
- Object updates shallow-merge by default, and setting a property to `undefined` deletes it.
63+
- The returned store is read through a proxy, and property reads track at the property level.
64+
- The setter supports both top-level updates and path syntax for nested updates.
65+
- Object updates shallow-merge by default, while single-array updates replace array contents. Setting a property to `undefined` deletes it.
6566
- Getters defined on the initial object remain available on the store.
6667

6768
## Examples
@@ -78,7 +79,7 @@ const [state, setState] = createStore({
7879
},
7980
});
8081

81-
setStore("user", "firstName", "Jane");
82+
setState("user", "firstName", "Jane");
8283
```
8384

8485
### Getter

src/routes/reference/store-utilities/unwrap.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Unwrapped value.
4444
- `unwrap` removes store proxies recursively and returns underlying plain data, reusing existing objects or arrays instead of cloning them when possible.
4545
- Frozen objects and arrays are shallow-copied before recursive unwrapping, while mutable ones are unwrapped in place.
4646
- Non-proxy input values are returned unchanged.
47+
- Mutating the returned value can mutate the underlying store data.
4748

4849
Do not assume `unwrap` produces an isolated deep clone.
4950

@@ -56,6 +57,8 @@ import { createStore, unwrap } from "solid-js/store";
5657

5758
const [state] = createStore({ user: { name: "John" } });
5859
const user = unwrap(state.user);
60+
61+
user.name = "Jane";
5962
```
6063

6164
## Related

0 commit comments

Comments
 (0)