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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fabulous.XamarinForms.SaveState" Version="2.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Fabulous.XamarinForms.SaveState --version 2.1.0                
#r "nuget: Fabulous.XamarinForms.SaveState, 2.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

  1. Add the Fabulous.XamarinForms.SaveState package to your project

  2. Open Fabulous.XamarinForms.SaveState at the top of the file where you declare your Fabulous program (eg. Program.stateful).

open Fabulous.XamarinForms.SaveState
  1. 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
  1. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 323 1/14/2023
2.0.0 329 10/20/2022

### 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