Description
The introduction of the core.Config system in v10 revealed a subtle timing issue in core.Base#set(). The implicit order of operations could cause a public field's setter (set myField()) to execute before the new values of reactive configs (myConfig_) from the same update batch were fully processed and available.
This refactoring hardens the initialization logic within core.Base to make it more explicit and robust in the context of the new v10 config system.
Changes Made in src/core/Base.mjs
isConfig() Modified:
- The method now checks for an active
configController (me.configController?.isConfig(key)) before checking the prototype chain. This makes config detection more robust in the v10 architecture.
setFields() Modified:
- This method's responsibility is now clearly defined: it identifies and immediately assigns simple public class fields (those without custom
get/set accessors).
set() Refactored:
- The
set() method's logic has been re-orchestrated to process properties in a strict, explicit order that resolves the timing dependency:
- Public Fields (via
setFields()): Simple, value-based public fields are assigned first.
- Reactive Configs: All reactive configs are processed next by adding them to the
configSymbol and running processConfigs().
- Public Fields with Accessors: Fields with custom
get()/set() methods are handled last. This guarantees their setters can now reliably access the final, updated values of all reactive configs from the same batch.
- Comprehensive JSDoc and inline comments were added to document this new, explicit order of operations.
Benefit
This refactoring establishes a clear and predictable order of operations within set(), restoring the expected behavior and ensuring that config hooks and custom field setters have a consistent and correct view of the instance's state during a batched update.
Description
The introduction of the
core.Configsystem in v10 revealed a subtle timing issue incore.Base#set(). The implicit order of operations could cause a public field's setter (set myField()) to execute before the new values of reactive configs (myConfig_) from the same update batch were fully processed and available.This refactoring hardens the initialization logic within
core.Baseto make it more explicit and robust in the context of the new v10 config system.Changes Made in
src/core/Base.mjsisConfig()Modified:configController(me.configController?.isConfig(key)) before checking the prototype chain. This makes config detection more robust in the v10 architecture.setFields()Modified:get/setaccessors).set()Refactored:set()method's logic has been re-orchestrated to process properties in a strict, explicit order that resolves the timing dependency:setFields()): Simple, value-based public fields are assigned first.configSymboland runningprocessConfigs().get()/set()methods are handled last. This guarantees their setters can now reliably access the final, updated values of all reactive configs from the same batch.Benefit
This refactoring establishes a clear and predictable order of operations within
set(), restoring the expected behavior and ensuring that config hooks and custom field setters have a consistent and correct view of the instance's state during a batched update.