You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mobx migration, vue compatibility, external system integration, mutable state
5
-
patterns, proxy-based reactivity
4
+
mutable proxy state, interop with mutable systems, object mutation through a
5
+
store proxy
6
6
tags:
7
7
- store
8
8
- mutable
9
9
- proxy
10
10
- state
11
-
- compatibility
12
11
version: "1.0"
13
12
description: >-
14
-
Create mutable proxy stores with automatic deep tracking. Ideal for MobX/Vue
15
-
compatibility or integrating external mutable systems.
13
+
Create a mutable store proxy.
16
14
---
17
15
18
-
`createMutable` creates a new mutable Store proxy object that provides a way to selectively trigger updates only when values change.
16
+
`createMutable` creates a mutable store proxy.
19
17
20
-
By intercepting property access, it allows automatic tracking of deep nesting via proxy making it useful for integrating external systems or serving as a compatibility layer with frameworks like MobX or Vue.
function createMutable<TextendsStoreNode>(state:T|Store<T>):Store<T>;
26
+
```ts
27
+
function createMutable<TextendsRecord<PropertyKey, any>>(
28
+
state:T,
29
+
options?: { name?:string }
30
+
):T;
27
31
```
28
32
29
-
:::note
30
-
It's important to recognize that a mutable state, which can be passed around and modified anywhere, may complicate the code structure and increase the risk of breaking unidirectional flow.
33
+
## Parameters
34
+
35
+
### `state`
36
+
37
+
-**Type:**`T`
38
+
39
+
Initial mutable state.
40
+
41
+
### `options`
42
+
43
+
#### `name`
44
+
45
+
-**Type:**`string`
46
+
47
+
Debug name used by development tooling.
48
+
49
+
## Return value
31
50
32
-
For a more robust alternative, it is generally recommended to use `createStore` instead.
33
-
Additionally, the [`produce`](/reference/store-utilities/produce) utility can provide many of these same benefits without the associated downsides.
51
+
-**Type:**`T`
34
52
35
-
:::
53
+
Mutable store proxy.
54
+
55
+
## Behavior
56
+
57
+
- Property reads and writes go through a proxy.
58
+
- Nested property access is reactive.
59
+
- Mutations update the store in place.
60
+
- Getters and setters defined on the initial object remain available on the mutable store.
complex state management, nested data, arrays and objects, derived values,
5
-
application state
4
+
object state, array state, nested state, structured application state
6
5
tags:
7
6
- store
8
7
- state
9
-
- data-structures
10
8
- objects
11
9
- arrays
12
10
version: "1.0"
13
11
description: >-
14
-
Manage complex application state with createStore. Handle nested objects,
15
-
arrays, and derived values with fine-grained reactivity.
12
+
Create a reactive store and a setter function for structured state.
16
13
---
17
14
18
-
Stores were intentionally designed to manage data structures like objects and arrays but are capable of handling other data types, such as strings and numbers.
15
+
`createStore` creates a reactive store and setter function for structured state.
0 commit comments