viewmodel

How to scope a view model to a parent fragment?

╄→гoц情女王★ 提交于 2020-07-30 05:57:08
问题 So I'm using the new navigation component (with the one activity principle) and communicating between each fragment using shared view models, however, I've come to a point where I sometimes need to clear the view model but I can't find a good place to clear it. But tbh I think rather than trying to clear it myself, I should really be allowing the framework to do it for me, but it doesn't because the view models are shared and scoped to the activity, but I think I can scope them to a parent

How to scope a view model to a parent fragment?

旧时模样 提交于 2020-07-30 05:55:00
问题 So I'm using the new navigation component (with the one activity principle) and communicating between each fragment using shared view models, however, I've come to a point where I sometimes need to clear the view model but I can't find a good place to clear it. But tbh I think rather than trying to clear it myself, I should really be allowing the framework to do it for me, but it doesn't because the view models are shared and scoped to the activity, but I think I can scope them to a parent

Unable to get provider androidx.lifecycle.ProcessLifecycleOwnerInitializr

99封情书 提交于 2020-07-20 07:21:28
问题 Getting error while running app which have dependencies 'androidx.lifecycle:lifecycle-extensions:2.1.0-alpha03' and 'androidx.lifecycle:lifecycle-viewmodel:2.1.0-alpha03' on device with Android 4.4. Works fine in device with Android 6 App getting crashed with error java.lang.RuntimeException: Unable to get provider androidx.lifecycle.ProcessLifecycleOwnerInitializer: java.lang.ClassNotFoundException: Didn't find class "androidx.lifecycle.ProcessLifecycleOwnerInitializer" on path: DexPathList[

C# - Retrieve data from persistence storage and save it to the view model

泄露秘密 提交于 2020-07-16 09:32:28
问题 Hello I have a controller method that I want to return the view model of that looks like this This is what it would look like if it was hard-coded public ActionResult SpecialOrderSummary(int? id) { // Retrieve data from persistence storage and save it to the view model. // But here I am just faking it. var vm = new ItemViewModel { ItemId = 123, ItemName = "Fake Item", Parts = new List<ItemPartViewModel> { new ItemPartViewModel { PartId = 1, PartName = "Part 1" }, new ItemPartViewModel {

C# - Retrieve data from persistence storage and save it to the view model

喜你入骨 提交于 2020-07-16 09:32:13
问题 Hello I have a controller method that I want to return the view model of that looks like this This is what it would look like if it was hard-coded public ActionResult SpecialOrderSummary(int? id) { // Retrieve data from persistence storage and save it to the view model. // But here I am just faking it. var vm = new ItemViewModel { ItemId = 123, ItemName = "Fake Item", Parts = new List<ItemPartViewModel> { new ItemPartViewModel { PartId = 1, PartName = "Part 1" }, new ItemPartViewModel {