didAttachToScope method
Invoked when the instance is successfully attached to its owning LevitScope.
Parameters:
scope: The LevitScope that manages this object.key: The unique registration key within the scope.
Implementation
@override
@mustCallSuper
void didAttachToScope(LevitScope scope, {String? key}) {
_scope = scope;
_registrationKey = key;
// Retroactively update ownerId for auto-disposed reactives
// This handles the case where variables are initialized before attachment
if (key != null) {
_cachedOwnerPath = null; // Force recalculation if key changed
final path = ownerPath;
for (final item in _disposables) {
if (item is LxReactive) {
if (item.ownerId != path) {
item.ownerId = path;
try {
item.refresh();
} catch (_) {}
}
}
}
}
}