[pull] androidx-main from androidx:androidx-main#1310
Merged
Conversation
- Inlined the `SavedStateHandleAttacher` logic by having `SavedStateHandleSupportController` implement `LifecycleEventObserver` directly, simplifying observer registration in `enableSavedStateHandles()`. - Inlined `createSavedStateHandle` helper function into the public `CreationExtras.createSavedStateHandle()` extension. - Nested the `ViewModel` class inside `SavedStateHandleSupportController` as a private `StateHolder` class, completely encapsulating it. - Simplified caching logic inside `createSavedStateHandle()` using Kotlin's `getOrPut` mapping function. - Used Kotlin class delegation (`by`) inside `SavedStateHandleSupportController` to delegate to `SavedStateRegistryOwner` and `ViewModelStoreOwner`. - Removed all private file/package-level extension properties. Test: existing passes Relnote: N/A Change-Id: I8169df0252e337544a39bd085ee3f28eb298bcbb
Consolidate the multiplatform SavedStateHandleSupportController and the legacy Android SavedStateHandleController into a unified SavedStateHandleController class in commonMain. Previously, Android and multiplatform targets managed SavedStateHandles differently. The legacy Android system used a reflection-based OnRecreation hook and addCloseable tags on ViewModels to reattach handles on recreation. That recreation hook crashed if the SavedStateRegistryOwner did not implement ViewModelStoreOwner. We consolidated this into the multiplatform StateHolder ViewModel system, which was already in place for CreationExtras. Because ViewModels survive configuration changes, we no longer need custom closeable tags to retain handles. To maintain backwards compatibility, the legacy factories (SavedStateViewModelFactory and AbstractSavedStateViewModelFactory) continue to register the reflection-based OnRecreation hook. The modern pathway (enableSavedStateHandles and createSavedStateHandle) completely bypasses it. Since retrieving the StateHolder requires a ViewModelStoreOwner, the owner parameter must implement this interface. We now enforce this at instantiation time (failing fast) instead of crashing later during recreation. RelNote: """`SavedStateViewModelFactory` and `AbstractSavedStateViewModelFactory` now fail-fast immediately if the provided `SavedStateRegistryOwner` does not implement `ViewModelStoreOwner`, preventing delayed crashes during component recreation.""" Test: SavedStateFactoryTest, SavedStateHandleSupportTest Change-Id: Icf31744863b188ad68aad7c253a8cdfc30f33ba1
* changes: Unify SavedStateHandleController Refactor SavedStateHandleSupport
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )