index ↓
store
client.store requests
you ask, the daemon answers. await the tagged result and check .ok
get(KVGet): Promise<TypedRequestResult<StorageResponse, never>>
push form: onResponse (subscribe instead of awaiting)
const res = await client.store.get({ key: '...' });
if (res.ok) {
console.log(res.response.key);
} type Result =
| { ok: true; response: StorageResponse }
| { ok: false; kind: 'domain'; error: never }
| { ok: false; kind: 'protocol'; error: WireError }; put(KVPut): Promise<TypedRequestResult<StorageResponse, never>>
push form: onResponse (subscribe instead of awaiting)
const res = await client.store.put({ key: '...', value: '...' });
if (res.ok) {
console.log(res.response.key);
} type Result =
| { ok: true; response: StorageResponse }
| { ok: false; kind: 'domain'; error: never }
| { ok: false; kind: 'protocol'; error: WireError }; delete(KVDelete): Promise<TypedRequestResult<StorageResponse, never>>
push form: onResponse (subscribe instead of awaiting)
const res = await client.store.delete({ key: '...' });
if (res.ok) {
console.log(res.response.key);
} type Result =
| { ok: true; response: StorageResponse }
| { ok: false; kind: 'domain'; error: never }
| { ok: false; kind: 'protocol'; error: WireError }; types
shapes referenced above, as the sdk types them
type KVGet = {
key: string;
}; type StorageResponse = {
key: string;
value?: string; // `null` after a `delete`, or when `get` finds no entry.
}; type KVPut = {
key: string;
value: string;
}; type KVDelete = {
key: string;
};