Update Programming Guide

2025-08-28 18:54:50 +02:00
parent 21bac63f72
commit 19e26f4bd5

@@ -181,11 +181,11 @@ Each context is fully isolated—changes in one do not affect any others—makin
## Best Practices ## Best Practices
* **Define keys as constants** centralize Key definitions to avoid typos and ensure consistency across the codebase. * **Define keys as constants** - centralize Key definitions to avoid typos and ensure consistency across the codebase.
* **Scope listeners carefully** register listeners only where reactive updates are needed; remove them when the owning component is disposed. (The framework uses weak references to help, but explicit cleanup is still good practice.) * **Scope listeners carefully** - register listeners only where reactive updates are needed; remove them when the owning component is disposed. (The framework uses weak references to help, but explicit cleanup is still good practice.)
* **Use descriptive, unique key names** this prevents accidental collisions within a context and improves readability. * **Use descriptive, unique key names** - this prevents accidental collisions within a context and improves readability.
* **Separate concerns with multiple contexts** create distinct contexts (e.g., "order", "user", "session") to isolate unrelated data and reduce coupling. * **Separate concerns with multiple contexts** - create distinct contexts (e.g., "order", "user", "session") to isolate unrelated data and reduce coupling.
* **Treat named contexts as ephemeral** hold onto a CtxInterface only for as long as you need it; once all strong references are gone, the context is automatically reclaimed by the garbage collector. * **Treat named contexts as ephemeral** - hold onto a CtxInterface only for as long as you need it; once all strong references are gone, the context is automatically reclaimed by the garbage collector.
## Complete Example ## Complete Example