mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Update docs
This commit is contained in:
parent
94add5d452
commit
a3cc2dfbda
30 changed files with 850 additions and 770 deletions
|
|
@ -3,7 +3,9 @@
|
|||
Explicitly creating effects to update properties is tedious. You can
|
||||
*implicitly* create an effect to update properties instead.
|
||||
|
||||
```luau
|
||||
::: code-group
|
||||
|
||||
```luau [Implicit Effect]
|
||||
local create = vide.create
|
||||
local source = vide.source
|
||||
|
||||
|
|
@ -22,6 +24,30 @@ local function Counter()
|
|||
end
|
||||
```
|
||||
|
||||
```luau [Explicit Effect]
|
||||
local create = vide.create
|
||||
local source = vide.source
|
||||
local effect = vide.effect
|
||||
|
||||
local function Counter()
|
||||
local count = source(0)
|
||||
|
||||
local instance = create "TextButton" {
|
||||
Activated = function()
|
||||
count(count() + 1)
|
||||
end
|
||||
}
|
||||
|
||||
effect(function()
|
||||
instance.Text = "count: " .. count()
|
||||
end)
|
||||
|
||||
return instance
|
||||
end
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
This example is equivalent to the example seen on the previous page.
|
||||
|
||||
Instead of explicitly creating an effect, assigning a (non-event) property a
|
||||
|
|
@ -46,12 +72,12 @@ local function List(props: { children: () -> { Instance } })
|
|||
}
|
||||
end
|
||||
|
||||
local list = List { children = items } -- creates a list with a single text label "A"
|
||||
local list = List { children = items } -- creates a list with text label "A"
|
||||
|
||||
items {
|
||||
create "TextLabel" { Text = "B" },
|
||||
create "TextLabel" { Text = "C" }
|
||||
}
|
||||
|
||||
-- this will automatically unparent the text label "A", and parent the labels "B" and "C"
|
||||
-- this will automatically unparent text label "A", and parent labels "B" and "C"
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue