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
- Storage on developer.repebble.com
Operations
writeInt
writeInt : Int -> Int -> Cmd msgStore an integer value under an integer key.
readInt
readInt : Int -> (Int -> msg) -> Cmd msgRead an integer by key and send it to toMsg.
writeString
writeString : Int -> String -> Cmd msgStore a string value under an integer key.
readString
readString : Int -> (String -> msg) -> Cmd msgRead a string by key and send it to toMsg.
delete
delete : Int -> Cmd msgRemove a stored value at key.
maxSize
maxSize : (Int -> msg) -> Cmd msgQuery the per-app persistent storage byte limit on this firmware.