mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Modification of type definitions and index for doc
This commit is contained in:
parent
f0916f71c5
commit
2a3e60581f
5 changed files with 33 additions and 12 deletions
|
|
@ -39,9 +39,9 @@ Runs a callback on state change.
|
|||
- ### Type
|
||||
|
||||
```lua
|
||||
function watch(callback: () -> ()): Unwatch
|
||||
|
||||
type Unwatch = () -> ()
|
||||
|
||||
function watch(callback: () -> ()): Unwatch
|
||||
```
|
||||
|
||||
- ### Details
|
||||
|
|
@ -58,15 +58,15 @@ Runs a callback on state change.
|
|||
- ### Example
|
||||
|
||||
```lua
|
||||
local state = wrap(1)
|
||||
local state = source(1)
|
||||
|
||||
watch(function()
|
||||
print(state.Value)
|
||||
print(state())
|
||||
end)
|
||||
|
||||
-- prints 1
|
||||
|
||||
state.Value += 1
|
||||
state(state() + 1)
|
||||
|
||||
-- prints 2
|
||||
```
|
||||
|
|
@ -99,7 +99,7 @@ Derives a new state from existing states.
|
|||
- ### Example
|
||||
|
||||
```lua
|
||||
local count = wrap(0)
|
||||
local count = source(0)
|
||||
local text = derive(function() return `count: {count()}` end)
|
||||
|
||||
text() -- "count: 0"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue