mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Update property nesting
Deeper nested properties guaranteed to be processed after shallower nested properties. Also added strict mode checks for duplicate nested properties.
This commit is contained in:
parent
ddb88cfdf8
commit
a769139136
5 changed files with 125 additions and 29 deletions
|
|
@ -43,7 +43,7 @@ export default defineConfig({
|
|||
{ text: "Source", link: "/tut/crash-course/4-source" },
|
||||
{ text: "Derived Source", link: "/tut/crash-course/5-derived-source" },
|
||||
{ text: "Table Source", link: "/tut/crash-course/6-table-source" },
|
||||
{ text: "Property Groups", link: "/tut/crash-course/7-property-groups" },
|
||||
{ text: "Nested Properties", link: "/tut/crash-course/7-nested-properties" },
|
||||
{ text: "Actions", link: "/tut/crash-course/8-actions" },
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ Currently, strict mode will:
|
|||
2. Run watchers twice when a source updates.
|
||||
3. Throw an error if yields occur where they are not allowed.
|
||||
4. Checks for `indexes()` and `values()` returning primitive values.
|
||||
5. Better error reporting and stack traces.
|
||||
5. Checks for duplicate nested properties at same depth.
|
||||
6. Better error reporting and stack traces.
|
||||
|
||||
By rerunning sources and watchers, any side-effects are made more apparent.
|
||||
This also helps ensure that cleanups are being handled correctly.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Property Groups
|
||||
# Nested Properties
|
||||
|
||||
Often when creating components from existing components, you can find yourself
|
||||
repetitively passing through properties such as size or position.
|
||||
|
|
@ -99,3 +99,22 @@ List {
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
Deeper nested properties are guaranteed to be set after shallower nested
|
||||
properties, this can be used to create overridable default properties.
|
||||
|
||||
```lua
|
||||
local function CenteredList(props: Children & Layout)
|
||||
return List {
|
||||
Layout = {
|
||||
props.Layout,
|
||||
|
||||
-- can be overriden by `props.Layout`
|
||||
AnchorPoint = Vector2.new(0.5, 0),
|
||||
Position = UDim2.fromScale(0.5, 0)
|
||||
},
|
||||
|
||||
Children = props.Children
|
||||
}
|
||||
end
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue