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