refactor!: remove peek

This commit is contained in:
littensy 2026-03-22 13:08:28 -07:00
parent 5c27052965
commit fd6b3efbb5
6 changed files with 70 additions and 262 deletions

View file

@ -50,7 +50,6 @@ Charm is a state management library based on [fine-grained reactivity](https://d
- [`observe(getter, callback)`](#observegetter-callback)
- [`subscribe(getter, callback)`](#subscribegetter-callback)
- [`untracked(callback)`](#untrackedcallback)
- [`peek(callback)`](#peekcallback)
- [`batch(callback)`](#batchcallback)
- [`mapped(getter, mapper)`](#mappedgetter-mapper)
- [`onCleanup(callback, failSilently?)`](#oncleanupcallback-failsilently)
@ -451,22 +450,6 @@ stopEffect() -- Cleaned up untracked effect
---
### `peek(callback)`
Similar to `untracked()`, but does not prevent the parent effect from tracking nested effects created in the callback. If your callback reads a signal and creates effects, only the signals get untracked.
```luau
local getCounter, setCounter = signal(0)
local disposeOuter = effect(function()
print(`Count is {peek(getCounter)}`)
end) -- Count is 0
setCounter(1) -- No output; count was accessed in peek()
```
---
### `batch(callback)`
Combines multiple signal updates made by the callback into a single commit that triggers effects once the callback completes.