ISuspensionHost interface¶
Defined in
Namespace: ReactiveUI
Assembly: ReactiveUI.dll
Full name: ReactiveUI.ISuspensionHost
Modifiers: public abstract
Summary¶
ISuspensionHost represents a standardized version of the events that the
host operating system publishes. Subscribe to these events in order to
handle app suspend / resume.
Applies to
net10.0, net10.0-android36.0, net10.0-ios26.0, net10.0-macos26.0, net10.0-windows10.0.19041, net10.0-tvos26.0, net10.0-maccatalyst26.0, net10.0-desktop1.0, net10.0-browserwasm1.0, net9.0, net9.0-tvos18.0, net9.0-maccatalyst18.0, net9.0-windows10.0.19041, net9.0-desktop1.0, net9.0-browserwasm1.0, net9.0-macos15.0, net9.0-ios18.0, net9.0-android35.0, net8.0, net8.0-macos14.5, net8.0-macos14.2, net8.0-maccatalyst17.5, net8.0-ios17.5, net8.0-tvos18.0, net8.0-macos15.0, net8.0-ios18.0, net8.0-windows10.0.19041, net8.0-maccatalyst18.0, net8.0-tvos17.2, netstandard2.1, net481, net462
Class hierarchy
classDiagram
class ISuspensionHost
class IReactiveObject {
<>
}
IReactiveObject <|.. ISuspensionHost
class INotifyPropertyChanged {
<>
}
INotifyPropertyChanged <|.. ISuspensionHost
class INotifyPropertyChanging {
<>
}
INotifyPropertyChanging <|.. ISuspensionHost
class IEnableLogger {
<>
}
IEnableLogger <|.. ISuspensionHost
Implements: IReactiveObject, INotifyPropertyChanged, INotifyPropertyChanging, IEnableLogger
Remarks¶
These observables abstract platform terms such as "Launching", "Activated", and "Closing" into a
consistent API so shared code can persist state without branching on specific UI stacks. Most
applications call RxSuspension.SuspensionHost.SetupDefaultSuspendResume() during startup to wire
default handlers, but the properties are public so advanced hosts can plug in their own monitoring.
AppState represents the serialized model describing the last running session, while CreateNewAppState can be configured to hydrate a fresh instance when a crash or first launch occurs.
Examples¶
<![CDATA[
var suspensionHost = RxSuspension.SuspensionHost;
suspensionHost.CreateNewAppState = () => new ShellState();
suspensionHost.IsLaunchingNew.Subscribe(_ =>
{
suspensionHost.AppState = suspensionHost.CreateNewAppState!();
});
suspensionHost.ShouldPersistState.Subscribe(disposable =>
{
storageService.Save((ShellState)suspensionHost.AppState!);
disposable.Dispose();
});
]]>
Properties¶
| Name | Summary |
|---|---|
| IsLaunchingNew | Gets or sets the observable which signals when the application is launching new. This can happen when an app has recently crashed, as well as the first time the app has been... |
| IsResuming | Gets or sets the observable which signals when the application is resuming from suspended state (i.e. it was previously running but its process was destroyed). |
| IsUnpausing | Gets or sets the observable which signals when the application is activated. Note that this may mean that your process was not actively running before this signal. |
| ShouldPersistState | Gets or sets the observable which signals when the application should persist its state to disk. |
| ShouldInvalidateState | Gets or sets the observable which signals that the saved application state should be deleted, this usually is called after an app has crashed. |
| CreateNewAppState | Gets or sets a function that can be used to create a new application state - usually this method just calls 'new' on an object. |
| AppState | Gets or sets the current application state - get a typed version of this via [GetAppState](# The "application... |