diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 380542a..633059e 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -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"} ] }, { diff --git a/docs/api/reactivity-dynamic.md b/docs/api/reactivity-dynamic.md index a3e5168..875c12f 100644 --- a/docs/api/reactivity-dynamic.md +++ b/docs/api/reactivity-dynamic.md @@ -32,7 +32,7 @@ Shows one of a set of components depending on a source and a mapping table. - **Type** ```luau - function switch(source: () -> K): (map: Map V>) () -> V? + function switch(source: () -> K): (map: Map V>): () -> V? ``` - **Details** diff --git a/docs/tut/dynamic-scoping/custom.md b/docs/tut/advanced/custom.md similarity index 99% rename from docs/tut/dynamic-scoping/custom.md rename to docs/tut/advanced/custom.md index 7a2ee62..99fe746 100644 --- a/docs/tut/dynamic-scoping/custom.md +++ b/docs/tut/advanced/custom.md @@ -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() @@ -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( input: () -> Map, transform: (value: () -> VI, index: I) -> VO diff --git a/docs/tut/crash-course/12-actions.md b/docs/tut/crash-course/12-actions.md index ba02618..60e5c30 100644 --- a/docs/tut/crash-course/12-actions.md +++ b/docs/tut/crash-course/12-actions.md @@ -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) diff --git a/docs/tut/crash-course/14-concepts.md b/docs/tut/crash-course/14-concepts.md index 8ed6a1a..f33d043 100644 --- a/docs/tut/crash-course/14-concepts.md +++ b/docs/tut/crash-course/14-concepts.md @@ -69,7 +69,7 @@ local count = source(0) root(function() local text = derive(function() - return "count: " .. text() + return "count: " .. count() end) effect(function() diff --git a/docs/tut/crash-course/5-effect.md b/docs/tut/crash-course/5-effect.md index e435034..82768dc 100644 --- a/docs/tut/crash-course/5-effect.md +++ b/docs/tut/crash-course/5-effect.md @@ -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 diff --git a/docs/tut/crash-course/6-scope.md b/docs/tut/crash-course/6-scope.md index a222e50..7775647 100644 --- a/docs/tut/crash-course/6-scope.md +++ b/docs/tut/crash-course/6-scope.md @@ -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 diff --git a/docs/tut/crash-course/7-reactive-component.md b/docs/tut/crash-course/7-reactive-component.md index ff67ec8..339ee4f 100644 --- a/docs/tut/crash-course/7-reactive-component.md +++ b/docs/tut/crash-course/7-reactive-component.md @@ -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() @@ -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