mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Add untrack()
This commit is contained in:
parent
0105e33fac
commit
6700e1b1f6
6 changed files with 107 additions and 2 deletions
|
|
@ -50,3 +50,35 @@ Runs a callback anytime a function scope is re-ran.
|
|||
return label
|
||||
end)
|
||||
```
|
||||
|
||||
## untrack()
|
||||
|
||||
Gets the value of a source without reactively tracking it.
|
||||
|
||||
- **Type**
|
||||
|
||||
```lua
|
||||
function untrack<T>(source: () -> T): T
|
||||
```
|
||||
|
||||
- **Details**
|
||||
|
||||
Updates made to a source passed to `untrack()` will not cause updates to
|
||||
anything depending on that source.
|
||||
|
||||
- **Example**
|
||||
|
||||
```lua
|
||||
local a = source(0)
|
||||
local b = source(0)
|
||||
|
||||
local sum = derive(function()
|
||||
return a() + untrack(b)
|
||||
end)
|
||||
|
||||
print(sum()) -- 0
|
||||
b(1)
|
||||
print(sum()) -- 0
|
||||
a(1)
|
||||
print(sum()) -- 2
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue