mirror of
https://github.com/littensy/charm.git
synced 2026-10-20 17:51:37 +00:00
docs: add warning for deep-charm and note for observe()
This commit is contained in:
parent
d1fa2cce92
commit
02be296b3d
2 changed files with 62 additions and 0 deletions
19
README.md
19
README.md
|
|
@ -885,6 +885,9 @@ You can opt-in to deep reactivity with the Deep Charm library:
|
|||
|
||||
### Installation
|
||||
|
||||
> [!WARNING]
|
||||
> Deep Charm is an experimental library that is not fully documented, and the API is subject to breaking changes.
|
||||
|
||||
```sh
|
||||
npm install @rbxts/deep-charm
|
||||
yarn add @rbxts/deep-charm
|
||||
|
|
@ -940,6 +943,22 @@ local proxy = reactive(raw)
|
|||
print(toRaw(proxy) == raw) -- true
|
||||
```
|
||||
|
||||
Calling `toRaw()` on a proxy also subscribes to its changes. This allows you to use proxies with `observe()` and other Charm APIs that accept a getter function:
|
||||
|
||||
```luau
|
||||
local proxy, updateProxy = reactive({})
|
||||
|
||||
observe(function()
|
||||
return toRaw(proxy)
|
||||
end, function(value, key)
|
||||
print(`Value {value} added at key {key}`)
|
||||
end)
|
||||
|
||||
updateProxy(function(state)
|
||||
table.insert(state, "foo")
|
||||
end) -- Value foo added at key 1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `isReactive(value)`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue