-
I am using framework converting to MAUI and trying to refactor my viewmodels to use more of the
Will the Shiny auto persistence work when Shiny.ViewModel is the base class for my view models? In my quick test it seems that I need to inherit from Shiny.NotifyPropertyChanged for persistence to work, but I am not sure this is correct or if I need to decorate properties when using Shiny.ViewModel. Is there a reason that Shiny.ViewModel doesn't inherit from Shiny.NotifyPropertyChanged? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Because [Reactive] is a part of ReactiveUI, not Shiny itself. Shiny frameworks viewmodel inherits from ReactiveObject which allows it to work with [Reactive]. Shiny.NotifyPropertyChanged is a base viewmodel for places where I don't have reactiveui throughout Shiny. Shiny auto persistence will only work if you call RememberUserState() in the ctor of the Shiny.ViewModel |
Beta Was this translation helpful? Give feedback.
-
Ok, so I can use Shiny.ViewModel and persist it as long as I call RememberUserState() for VMs that I want to persist with no changes to the [Reactive] properties? I don't need anything like [DataContract] [DataMemeber] to tell it to persist certain properties? In the past I had a persistence "manager" based around the reactive docs persistence, I think before you had the auto persist stuff or before I started adopting Shiny. Thanks for the info/help. |
Beta Was this translation helpful? Give feedback.
-
You only need to trigger a notify property change event (like the reactive attribute) and the viewmodel properties with get/set will be persisted and restored each time you visit that viewmodel that has RememberUserState turned on. |
Beta Was this translation helpful? Give feedback.
You only need to trigger a notify property change event (like the reactive attribute) and the viewmodel properties with get/set will be persisted and restored each time you visit that viewmodel that has RememberUserState turned on.