The PortFunnelLocalStorage uses the JavaScript localStorage facility to persistently store key/value pairs.
It is a billstclair/elm-port-funnel PortFunnel funnel.
A Response is used to return values for Get and ListKeys.
Our internal state.
A convenience type for keys in the store. Same as String.
A convenience type for prefixes. Same as String.
A convenience type for values in the store. Same as Json.Encode.Value.
PortFunnel.FunnelSpecThe name of this funnel: "LocalStorage".
Our module descriptor.
Responsible for sending a CmdResponse back through the port.
This funnel doesn't initiate any sends, so this function always returns Cmd.none.
StateThe initial state.
The Prefix arg (plus a period, if non-blank) is prepended to all
keys sent to the backend, and removed from keys returned. It basically
give you a namespace in local storage, and usually matches your
application name. It allows multiple different Elm applications to be
served by the same domain without stepping on each other's state.
The state also stores a Dict, which acts as the backing store for simulation,
and a flag saying whether the JavaScript code has sent its "I'm loaded" message
(see isLoaded).
Message out the Cmd PortSend a Message through a Cmd port.
Note that this send function requires that you pass state,
but it is read-only, so you don't need to update your Model state
on return.
The Message type is opaque, so there are functions to create the four messages
you may pass to send.
Return a Message to put a value into local storage.
Nothing for the value means to remove the key.
Return a message to remove all keys beginning with a prefix.
A prefix of "" means to remove all keys.
Convert a Message to the same JSON string that gets sent
over the wire to the JS code.
Make a simulated Cmd port.
Returns true if a Startup message has been processed.
This is sent by the port code after it has initialized. Your code can use this to decide whether to use your real outgoing port or the one created by makeSimulatedCmdPort.
An opaque type that represents message to send and receive from the JS code.
There are a number of internal messages, but the ones you can use are created by
get,put,listkeys, andclear.