A minimal local storage API that mirrors the raw API very closely.
String -> Platform.Cmd.Cmd msg
Port to clear the whole area of local storage underneath a prefix.
String -> Platform.Cmd.Cmd msg
Port to fetch an item by its key and prefix.
( String
, Json.Encode.Value ) -> Platform.Cmd.Cmd ms
)
Port to set the value of an item by key and prefix.
String -> Platform.Cmd.Cmd msg
Port to list the available local storage keys underneath a prefix.
(Json.Encode.Value -> msg) -> Platform.Sub.Sub msg
Subscription port to listen to all operation responses from local storage with.
The type of the local storage handle, required to perform operations on local storage.
make : GetItemPort msg -> SetItemPort msg -> ClearPort msg -> ListKeysPort msg -> String -> LocalStorage msg
Builds local storage using the supplied port implementations and a prefix to namespace all keys stored in that area of local storage.
clear : LocalStorage msg -> Platform.Cmd.Cmd msg
Clears the whole area of local storage underneath a prefix.
getItem : LocalStorage msg -> String -> Platform.Cmd.Cmd msg
Fetches an item by its key and prefix.
setItem : LocalStorage msg -> String -> Json.Encode.Value -> Platform.Cmd.Cmd msg
Sets the value of an item by key and prefix.
listKeys : LocalStorage msg -> String -> Platform.Cmd.Cmd msg
Lists the available local storage keys underneath a prefix.
The possible local storage operation responses.
responseHandler : (Response -> msg) -> LocalStorage msg -> Json.Encode.Value -> msg
Creates a response handler to use with the ResponsePort
subscription port.
The operation, key and JSON value message builder combined with the storage prefix are needed to create a response handler.