Update docs

This commit is contained in:
Aaron Smith 2023-09-28 16:39:25 +01:00
parent 9b6be14441
commit 46937c6979
16 changed files with 157 additions and 116 deletions

View file

@ -5,6 +5,8 @@ A stateful component is a component that stores and displays some data.
Stateful components in Vide are created using sources and effects - sources to
store the data, and effects to display the data.
## Internal State
```lua
local create = vide.create
local source = vide.source
@ -30,12 +32,14 @@ end
Above is an example of a counter component, that when clicked, will increment
its internal count, and automatically update its text to reflect that count.
Making a property update based on a source is also called *property
Making a property update based on a source is also referred to as *property
binding*.
Each instance of `Counter()` will maintain its own independent count, since the
count source is created inside the scope of the component.
## External State
External sources can also be passed into components for them to use.
```lua
@ -65,5 +69,5 @@ count(1) -- the Counter component will update to display this count
```
Sources can be created internally or passed in from externally, there are no
restrictions on how they are used as long as the effect is created within a
reactive scope so that it can be tracked.
restrictions on how they are used as long as the effect using it is created
within a reactive scope so that it can be cleaned up later.