RenaiApp/src/renderer/services/store.ts

17 lines
425 B
TypeScript
Raw Normal View History

import { writable } from 'svelte/store';
import * as api from './api';
const { subscribe, set } = writable<boolean>(false);
export const loggedIn = {
subscribe,
fetchIsLoggedIn(): Promise<void> {
return api.isLoggedIn().then((isLoggedIn: boolean) => {
set(isLoggedIn);
});
},
fetchLogin(credentials: ICredentials): Promise<void> {
return api.login(credentials).then(this.fetchIsLoggedIn);
},
};