dyomedea/src/db/state.ts

26 lines
522 B
TypeScript
Raw Normal View History

import { get, put } from './lib';
interface State {
lon: number;
lat: number;
rotation: number;
zoom: number;
provider: string;
}
export const getState = async <State>() => {
try {
const state = (await get('state', true)).doc;
console.log({ caller: 'getState', state });
return state;
} catch {
return null;
}
};
export const setState = async (state: State) => {
await put('state', 'state', (doc) => state, {}, true);
console.log({ caller: 'setState', state });
return 'state';
};