Pebble.Storage

Watch-local key/value storage commands.

The watch runtime exposes a lightweight integer- and string-keyed store. Keys are integers; values can be ints or strings. Use maxSize to learn the per-app byte limit on the current firmware.

import Pebble.Storage as Storage

storageKey : Int
storageKey =
    1

type Msg
    = CounterLoaded Int
    | MaxSizeLoaded Int

init _ =
    ( model
    , Cmd.batch
        [ Storage.readInt storageKey CounterLoaded
        , Storage.maxSize MaxSizeLoaded
        ]
    )

saveCounter : Int -> Cmd msg
saveCounter value =
    Storage.writeInt storageKey value

For a runnable example, use the watch-demo-storage project template in the IDE.

Native Pebble C API

Operations

writeInt

writeInt : Int -> Int -> Cmd msg

Store an integer value under an integer key.

readInt

readInt : Int -> (Int -> msg) -> Cmd msg

Read an integer by key and send it to toMsg.

writeString

writeString : Int -> String -> Cmd msg

Store a string value under an integer key.

readString

readString : Int -> (String -> msg) -> Cmd msg

Read a string by key and send it to toMsg.

delete

delete : Int -> Cmd msg

Remove a stored value at key.

maxSize

maxSize : (Int -> msg) -> Cmd msg

Query the per-app persistent storage byte limit on this firmware.