Distribute and handle challenge.json

This commit is contained in:
nemunaire 2022-05-01 22:33:59 +02:00
commit dff4f4eb63
20 changed files with 167 additions and 48 deletions

View file

@ -0,0 +1,22 @@
import { readable, writable } from 'svelte/store';
function createChallengeStore() {
const { subscribe, set, update } = writable({});
return {
subscribe,
update: (res_challenge, cb) => {
if (res_challenge.status === 200) {
res_challenge.json().then((challenge) => {
update((s) => (Object.assign({}, challenge)));
if (cb) {
cb(challenge);
}
});
}
},
}
}
export const challengeInfo = createChallengeStore();