mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Improve Documentation Site (#41)
* update css and snippets * Add banner * improve home page * Update Banner * cleanup * Update font to JetBrains Mono * Add a quick look to Home * Simplify Home Page * Removed banner, removed copyright notice, reduced home page
This commit is contained in:
parent
f7dac3f63a
commit
f8e84f9f8d
29 changed files with 255 additions and 184 deletions
|
|
@ -5,7 +5,7 @@ a side-effect from a source update. Vide provides a function `cleanup()` which
|
|||
is used to queue a callback for the next time a reactive scope is rerun or
|
||||
destroyed, or when a stable scope is destroyed.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local root = vide.root
|
||||
local source = vide.source
|
||||
local effect = vide.effect
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ instance.
|
|||
update to display the current value at that index. Each table index is given a
|
||||
single corresponding UI element.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local list = source {
|
||||
"finish the crash course",
|
||||
"star Vide's GitHub"
|
||||
|
|
@ -90,7 +90,7 @@ end
|
|||
When you edit a table in a source, you must set that table again to actually
|
||||
update the source.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local src = source { 1, 2 }
|
||||
local data = src()
|
||||
table.insert(data, 3) -- no effects will run
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
Actions in Vide are special callbacks that you can pass along with properties,
|
||||
to run some code on an instance receiving them.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local action = vide.action
|
||||
```
|
||||
|
||||
```lua
|
||||
```luau
|
||||
create "TextLabel" {
|
||||
Text = "test",
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ create "TextLabel" {
|
|||
Actions can be wrapped with functions for reuse. Below is an example of an
|
||||
action used to listen for property changes:
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local action = vide.action
|
||||
local effect = vide.effect
|
||||
local cleanup = vide.cleanup
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Strict mode will run derived sources and effects twice each time they update.
|
|||
This is to help ensure that derived source computations are pure, and that any
|
||||
cleanups made in derived sources or effects are done properly.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local source = vide.source
|
||||
local effect = vide.effect
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ relationships between effects and the sources they depend on.
|
|||
|
||||
### Code
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local count = source(0)
|
||||
|
||||
root(function()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ Instances are created using `create()`.
|
|||
Parentheses `()` can be omitted when calling functions with string or
|
||||
table literals for brevity.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local create = vide.create
|
||||
|
||||
return create "ScreenGui" {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ together.
|
|||
|
||||
::: code-group
|
||||
|
||||
```lua [Button.luau]
|
||||
```luau [Button.luau]
|
||||
local create = vide.create
|
||||
|
||||
local function Button(props: {
|
||||
|
|
@ -34,7 +34,7 @@ end
|
|||
return Button
|
||||
```
|
||||
|
||||
```lua [Menu.luau]
|
||||
```luau [Menu.luau]
|
||||
local create = vide.create
|
||||
|
||||
local Button = require(Button)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ Vide's reactivity.
|
|||
|
||||
A source can be created using `source()`.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local source = vide.source
|
||||
|
||||
local count = source(0)
|
||||
|
|
@ -16,13 +16,13 @@ The value passed to `source()` is the initial value of the source.
|
|||
The value of a source can be set by calling it with an argument, and can be read
|
||||
by calling it with no arguments.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
count(count() + 1) -- increment count by 1
|
||||
```
|
||||
|
||||
Sources can be *derived* by wrapping them in functions.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local count = source(0)
|
||||
|
||||
local text = function()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ A source and effect is analogous to a signal and connection.
|
|||
|
||||
Effects are created using `effect()`.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local source = vide.source
|
||||
local effect = vide.effect
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ that source is updated.
|
|||
Derived sources are also tracked, it doesn't matter how deeply nested
|
||||
inside a function a source is.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local source = vide.source
|
||||
local effect = vide.effect
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ destroyed, and so on. This is why all scopes must be created within another
|
|||
scope, except `root()` which is used to create the initial scope that you can
|
||||
manually destroy.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local root = vide.root
|
||||
local source = vide.source
|
||||
local effect = vide.effect
|
||||
|
|
@ -45,7 +45,7 @@ count(1) -- prints "1"
|
|||
|
||||
The scope created by `root()` can be destroyed.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local function setup()
|
||||
local count = source(0)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ store the data, and effects to display the data.
|
|||
|
||||
## Internal State
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local create = vide.create
|
||||
local source = vide.source
|
||||
local effect = vide.effect
|
||||
|
|
@ -37,7 +37,7 @@ count source is created inside the component.
|
|||
|
||||
External sources can also be passed into components for them to use.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local function Counter(props: { count: () -> number })
|
||||
local count = props.count
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Explicitly creating effects to update properties is tedious. You can
|
||||
*implicitly* create an effect to update properties instead.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local create = vide.create
|
||||
local source = vide.source
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ with a number key instead of string key) can return an instance or an array of
|
|||
instances. An effect is automatically created to unparent removed instances and
|
||||
parent new instances on source update.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local items = source {
|
||||
create "TextLabel" { Text = "A" }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
We have seen the basic way to derive a source:
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local count = source(0)
|
||||
|
||||
local text = function()
|
||||
|
|
@ -18,7 +18,7 @@ However, in some cases where this source could be used by multiple effects at
|
|||
the same time, the function wrapping the source will needlessly rerun to convert
|
||||
the count into a string for each effect using it.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local source = vide.source
|
||||
local effect = vide.effect
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ To avoid this, you can use `derive()` to derive a new source instead. This will
|
|||
run a function in a reactive scope only when a source used inside updated.
|
||||
Reading this derived source multiple times will just return a cached result.
|
||||
|
||||
```lua
|
||||
```luau
|
||||
local source = vide.source
|
||||
local effect = vide.effect
|
||||
local derive = vide.derive
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue