AutoSuspendHelper class¶
Defined in
Namespace: ReactiveUI.Maui
Assembly: ReactiveUI.Maui.dll
Full name: ReactiveUI.Maui.AutoSuspendHelper
Modifiers: public
Summary¶
Helps manage .NET MAUI application lifecycle events.
Applies to
net10.0, net10.0-android36.0, net10.0-ios26.0, net10.0-macos26.0, net10.0-windows10.0.19041, net10.0-browserwasm1.0, net10.0-desktop1.0, net10.0-tvos26.0, net10.0-maccatalyst26.0, net9.0, net9.0-tvos18.0, net9.0-maccatalyst18.0, net9.0-windows10.0.19041, net9.0-browserwasm1.0, net9.0-macos15.0, net9.0-ios18.0, net9.0-android35.0, net9.0-desktop1.0, net8.0-macos15.0, net8.0-ios18.0, net8.0-maccatalyst18.0, net8.0-tvos18.0, netstandard2.1
Class hierarchy
classDiagram
class AutoSuspendHelper
class IEnableLogger {
<>
}
IEnableLogger <|.. AutoSuspendHelper
class IDisposable {
<>
}
IDisposable <|.. AutoSuspendHelper
Implements: IEnableLogger, IDisposable
Remarks¶
Instantiate this class to wire SuspensionHost to MAUI's Application
callbacks. The helper propagates OnStart, OnResume, and OnSleep to the suspension host so state
drivers created via SetupDefaultSuspendResume can serialize view models consistently across Android, iOS, and
desktop targets.
Sample usage of AutoSuspendHelper is shown below.
<![CDATA[
public partial class App : Application
{
private readonly AutoSuspendHelper _autoSuspendHelper;
public App()
{
_autoSuspendHelper = new AutoSuspendHelper();
RxSuspension.SuspensionHost.CreateNewAppState = () => new MainState();
RxSuspension.SuspensionHost.SetupDefaultSuspendResume(new FileSuspensionDriver(FileSystem.AppDataDirectory));
_autoSuspendHelper.OnCreate();
InitializeComponent();
MainPage = new MainView();
}
protected override void OnStart() => _autoSuspendHelper.OnStart();
protected override void OnResume() => _autoSuspendHelper.OnResume();
protected override void OnSleep() => _autoSuspendHelper.OnSleep();
}
]]>
Constructors¶
| Name | Summary |
|---|---|
| .ctor | Initializes a new instance of the [AutoSuspendHelper](# class. |
Properties¶
| Name | Summary |
|---|---|
| static UntimelyDemise | Gets a subject to indicate whether the application has crashed. |
Methods¶
| Name | Summary |
|---|---|
| OnCreate | Call this method in the constructor of your .NET MAUI Application. |
| OnStart | Call this method in OnStart to relay MAUI's start notification. |
| OnSleep | Call this method in OnSleep when the app is going to the background. |
| OnResume | Call this method in OnResume when the app returns to the foreground. |
| Dispose |