You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/core/Base.mjs
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,13 @@ class Base {
71
71
* - `beforeSetMyConfig(newValue, oldValue)`: Executed before a new value is set. Can be used for validation or transformation. Returning `undefined` from this hook will cancel the update.
72
72
* - `afterSetMyConfig(newValue, oldValue)`: Executed after a new value has been successfully set. Ideal for triggering side effects.
73
73
*
74
+
* **The `undefined` Sentinel Value:**
75
+
* In Neo.mjs, `undefined` is used as a strict, immutable sentinel value representing "initial instantiation".
76
+
* When an `afterSet` hook runs for the very first time during component creation, its `oldValue` will ALWAYS be `undefined`.
77
+
* This allows developers to easily skip logic that should not run during setup using a simple `if (oldValue !== undefined)`.
78
+
* Because of this architecture, **you should never set a config to `undefined` later in its lifecycle.**
79
+
* If you need to clear or reset a config's state, explicitly set it to `null`.
80
+
*
74
81
* 2. **Non-Reactive (Prototype-based) Configs:** Property names without a trailing underscore.
75
82
* These are applied directly to the class's **prototype** during the `Neo.setupClass`
76
83
* process. This is highly memory-efficient as the value is shared across all instances.
0 commit comments