我如何在Elm的本地存储中保存应用程序状态

问题描述 投票:0回答:1

我想将整个应用程序状态缓存在浏览器本地存储中。我的模型是一种由各种类型组成的结帐页面,这是Model类型的别名:

type alias Model =
{ showCheckoutModal : Bool
, showAddressForm : Bool
, emailAddress : String
, address : Address
, selectedAddress : Maybe Address
, addresses : List Address
, name : String
, listings : List Listing
, shop : Maybe Shop
, shop_id : String
, shippingInfo : ShippingInfo
, selectedDestination : Maybe ShippingDestination
}

我已经创建了传出端口和传入端口

port outgoing : OutgoingMsg -> Cmd msg

port incoming : (E.Value -> msg) -> Sub msg

所以,我进行了一些研究,可以完成,但是所有在线示例都是更简单的模型,对于像我这样复杂的模型,我还没有看到任何例子。请多谢,谢谢

javascript elm
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.