WIP Svelte

This commit is contained in:
nemunaire 2021-11-18 12:12:28 +01:00
commit ded0e8e1c8
48 changed files with 3976 additions and 46 deletions

View file

@ -0,0 +1,27 @@
import { writable } from 'svelte/store';
function createUserStore() {
const { subscribe, set, update } = writable(undefined);
return {
subscribe,
set: (auth) => {
update((m) => auth);
},
update: (res_auth, cb=null) => {
if (res_auth.status === 200) {
res_auth.json().then((auth) => {
update((m) => (Object.assign(m?m:{}, auth)));
if (cb) {
cb(my);
}
});
} else if (res_auth.status >= 400 && res_auth.status < 500) {
update((m) => (null));
}
},
};
}
export const user = createUserStore();