Add untrack()

This commit is contained in:
Aaron Smith 2023-08-22 12:12:03 +01:00
parent 0105e33fac
commit 6700e1b1f6
6 changed files with 107 additions and 2 deletions

View file

@ -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
```