Coder Social home page Coder Social logo

reigam / fabulous.xamarinforms.savestate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fabulous-dev/fabulous.xamarinforms.savestate

0.0 0.0 0.0 6.1 MB

Add the save state feature to your Fabulous.XamarinForms app

License: Other

F# 100.00%

fabulous.xamarinforms.savestate's Introduction

Fabulous.XamarinForms.SaveState

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

fabulous.xamarinforms.savestate's People

Contributors

timlariviere avatar reigam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.