mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
This commit is contained in:
parent
5a458eae71
commit
68ff117be9
19 changed files with 80 additions and 83 deletions
|
|
@ -50,16 +50,16 @@ Creates a new source with the given value.
|
|||
count(count() + 1) -- 1
|
||||
```
|
||||
|
||||
## watch()
|
||||
## effect()
|
||||
|
||||
Runs a callback on source update.
|
||||
|
||||
- **Type**
|
||||
|
||||
```lua
|
||||
function watch(source: () -> ()): Unwatch
|
||||
function effect(source: () -> ()): Uneffect
|
||||
|
||||
type Unwatch = () -> ()
|
||||
type Uneffect = () -> ()
|
||||
```
|
||||
|
||||
- **Details**
|
||||
|
|
@ -70,7 +70,7 @@ Runs a callback on source update.
|
|||
Any time a source referenced in the callback is changed, the callback will
|
||||
be reran.
|
||||
|
||||
Also returns a function that when called, stops the watcher immediately.
|
||||
Also returns a function that when called, stops the effecter immediately.
|
||||
|
||||
::: warning
|
||||
`source()` cannot yield.
|
||||
|
|
@ -81,7 +81,7 @@ Runs a callback on source update.
|
|||
```lua
|
||||
local state = source(1)
|
||||
|
||||
watch(function()
|
||||
effect(function()
|
||||
print(state())
|
||||
end)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue