+ Ma is now Delegate

+ way to add pure Lyng parents when declaring kotlin bindings
This commit is contained in:
sergeych committed 2026-01-06 13:11:07 +01:00
1 parent 3ef68d8bb4
commit 3941ddee40
7 files changed
+136 -2

No files matched your search

+13
View File
@@ -224,6 +224,19 @@ A delegate is any object that provides the following methods (all optional depen
- `invoke(thisRef, name, args...)`: Called when a delegated `fun` is invoked.
- `bind(name, access, thisRef)`: Called once during initialization to configure or validate the delegate.
### Map as a Delegate
Maps can also be used as delegates. When delegated to a property, the map uses the property name as the key:
```lyng
val settings = { "theme": "dark", "fontSize": 14 }
val theme by settings
var fontSize by settings
println(theme) // "dark"
fontSize = 16 // Updates settings["fontSize"]
```
For more details and advanced patterns (like `lazy`, `observable`, and shared stateless delegates), see the [Delegation Guide](delegation.md).
## Instance initialization: init block