New methods to override for ViewModelBase in TinyMvvm

In the latest preview of TinyMvvm, 4.0.1-pre4, there are new methods added to the ViewModelBase class. The new methods will make it easier to handle App lifecycle events in a ViewModel. For example, if you want to unsubscribe from an event when the app goes to sleep. Before you had to handle this in the Application class.

Following methods has been added for you to override:

  • Task OnApplicationResume();
  • Task OnApplicationSleep();

Those new features are available for both TinyMvvm.Forms (for Xamarin.Forms) and TinyMvvm.Maui (for .NET MAUI). To make them work you need to change the base class of your App class to TinyApplication instead of Application.

If you don't want to change to TinyApplication, nothing old will be broken, but the new methods will not work.

The code for this release is currently just in the maui branch,

  12/29/2021 - 6:04 AM