Fabulous.XamarinForms.SaveState
2.1.0
dotnet add package Fabulous.XamarinForms.SaveState --version 2.1.0
NuGet\Install-Package Fabulous.XamarinForms.SaveState -Version 2.1.0
<PackageReference Include="Fabulous.XamarinForms.SaveState" Version="2.1.0" />
paket add Fabulous.XamarinForms.SaveState --version 2.1.0
#r "nuget: Fabulous.XamarinForms.SaveState, 2.1.0"
// Install Fabulous.XamarinForms.SaveState as a Cake Addin #addin nuget:?package=Fabulous.XamarinForms.SaveState&version=2.1.0 // Install Fabulous.XamarinForms.SaveState as a Cake Tool #tool nuget:?package=Fabulous.XamarinForms.SaveState&version=2.1.0
Save state extension for Fabulous.XamarinForms
Add the save state feature to your Fabulous.XamarinForms app.
This package will automatically save the current state of your app when it is suspended and restore it when it is resumed.
How to use
Add the Fabulous.XamarinForms.SaveState package to your project
Open
Fabulous.XamarinForms.SaveState
at the top of the file where you declare your Fabulous program (eg.Program.stateful
).
open Fabulous.XamarinForms.SaveState
- Add an additional Msg case to your app to handle the state save failure.
type Msg =
| StateSaveFailure of exn // This one will be called if the serialization fails
| ... // Other messages
- After the declaration of your Fabulous program, add the
withSaveState
function.
(This example uses Newtonsoft.Json to serialize and deserialize the app state)
let encodeAppState (model: Model): string = JsonConvert.SerializeObject(model)
let decodeAppState (encodedState: string): Model = JsonConvert.DeserializeObject<Model>(encodedState)
let program =
Program.stateful init update view
|> Program.withSaveState encodeAppState decodeAppState StateSaveFailure
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Fabulous.XamarinForms (>= 2.1.0 && < 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
### Changed
- Updated dependency on Fabulous.XamarinForms to limit between 2.1.0 to 2.2.0 to ensure SaveState can only be used with a binary-compatible version