metawrite
Version:
Appwrite SDK with ready to go components for Svelte / SvelteKit
29 lines (28 loc) • 773 B
JavaScript
import { SDK as Appwrite } from '../_appwrite';
import { writable } from 'svelte/store';
export class UserStore {
constructor() {
const { subscribe, set, update } = writable(null);
this.subscribe = subscribe;
this.set = set;
this.update = update;
}
/**
* Reload the current User.
* @returns {Promise<Models.User<Models.Preferences>>}
*/
async reload() {
const response = await Appwrite.sdk.account.get();
this.set(response);
return response;
}
/**
* Logout the current User.
* @returns {Promise<object>}
*/
async logout() {
const response = await Appwrite.sdk.account.deleteSession('current');
this.set(null);
return response;
}
}