Skip to content

Commit

Permalink
Fix mistakes in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
centau committed Nov 12, 2024
1 parent baf308c commit bacb4fa
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default withMermaid({
{
text: "Dynamic Scoping",
items: [
{ text: "Custom Scopes", link: "/tut/dynamic-scoping/custom"}
{ text: "Custom Scopes", link: "/tut/advanced/custom"}
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/api/reactivity-dynamic.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Shows one of a set of components depending on a source and a mapping table.
- **Type**
```luau
function switch<K, V>(source: () -> K): (map: Map<K, () -> V>) () -> V?
function switch<K, V>(source: () -> K): (map: Map<K, () -> V>): () -> V?
```
- **Details**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ as a guard against unintentional rerendering of UI.

## Recreating [`switch()`](/api/reactivity-dynamic#switch-reactive)

```lua
```luau
local function switch(key)
return function(map)
return derive(function()
Expand All @@ -76,7 +76,7 @@ between reruns, we cannot use `untrack()` anymore which automatically destroys
on rerun; we must use `root()` where the lifetime of each scope is managed
manually and independently.

```lua
```luau
local function indexes<I, VI, VO>(
input: () -> Map<I, VI>,
transform: (value: () -> VI, index: I) -> VO
Expand Down
4 changes: 2 additions & 2 deletions docs/tut/crash-course/12-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ local source = vide.source
local effect = vide.effect
local cleanup = vide.cleanup
local function changed(prop: string, callback: (new) -> ())
local function changed(property: string, callback: (new) -> ())
return action(function(instance)
local connection = instance:GetPropertyChangedSignal(prop):Connect(function()
local connection = instance:GetPropertyChangedSignal(property):Connect(function()
callback(instance[property])
end)
Expand Down
2 changes: 1 addition & 1 deletion docs/tut/crash-course/14-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ local count = source(0)
root(function()
local text = derive(function()
return "count: " .. text()
return "count: " .. count()
end)
effect(function()
Expand Down
2 changes: 1 addition & 1 deletion docs/tut/crash-course/5-effect.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ effects depending on it.

You can also read from a source within an effect without the effect tracking it.

```lua
```luau
local source = vide.source
local effect = vide.effect
local untrack = vide.untrack
Expand Down
2 changes: 0 additions & 2 deletions docs/tut/crash-course/6-scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ local function setup()
effect(function()
print(count())
end)
return count
end
setup() -- error, effect() tried to create a reactive scope with no stable scope
Expand Down
12 changes: 4 additions & 8 deletions docs/tut/crash-course/7-reactive-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ count source is created inside the component.
External sources can also be passed into components for them to use.

```luau
local function Counter(props: { count: () -> number })
local function CountDisplay(props: { count: () -> number })
local count = props.count
local instance = create "TextButton" {
Activated = function()
count(count() + 1)
end
}
local instance = create "TextLabel" {}
effect(function()
instance.Text = "count: " .. count()
Expand All @@ -52,11 +48,11 @@ end
local count = source(0)
Counter {
CountDisplay {
count = count
}
count(1) -- the Counter component will update to display this count
count(1) -- the CountDisplay component will update to display this count
```

Sources can be created internally or passed in from externally, there are no
Expand Down

0 comments on commit bacb4fa

Please sign in to comment.