Distribute and handle challenge.json
This commit is contained in:
parent
e8f6a03cd9
commit
dff4f4eb63
20 changed files with 167 additions and 48 deletions
22
frontend/ui/src/stores/challengeinfo.js
Normal file
22
frontend/ui/src/stores/challengeinfo.js
Normal 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();
|
||||
Reference in a new issue