mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 03:36:11 +00:00
refactor!: remove peek
This commit is contained in:
parent
5c27052965
commit
fd6b3efbb5
6 changed files with 70 additions and 262 deletions
17
README.md
17
README.md
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue