Closed vlazzle closed 7 years ago
Awesome spot, thanks! Now injecting a Factory for the ViewModel (https://github.com/bufferapp/clean-architecture-components-boilerplate/blob/master/presentation/src/main/java/org/buffer/android/boilerplate/presentation/browse/BrowseBufferoosViewModelFactory.kt) and then using this when fetching the ViewModel from the provider (https://github.com/bufferapp/clean-architecture-components-boilerplate/blob/master/mobile-ui/src/main/java/org/buffer/android/boilerplate/ui/browse/BrowseActivity.kt#L34)
Thanks again!
Great! You're very welcome
On Mon, Sep 25, 2017, 9:33 PM Joe Birch notifications@github.com wrote:
Closed #3 https://github.com/bufferapp/clean-architecture-components-boilerplate/issues/3 .
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bufferapp/clean-architecture-components-boilerplate/issues/3#event-1263511460, or mute the thread https://github.com/notifications/unsubscribe-auth/AABQdTf_ML1uk6coRFwuzQOWGYOCnBiaks5sl4-jgaJpZM4PhuPS .
Steps to repro:
android.arch.lifecycle.ViewModel
s are meant to survive config changes.BrowseBufferoosViewModel will survive config changes if it's retrieved in BrowseActivity the normal way using
ViewModelProviders.of
. If you prefer to inject with dagger, take a look at this sample, then retrieve the ViewModel like so