]> git.r.bdr.sh - rbdr/corona-regeln/blob - src/lib/stores/rules.js
8c2755eda331e0fb1477b1df887992802a9f85d7
[rbdr/corona-regeln] / src / lib / stores / rules.js
1 import { readable } from 'svelte/store';
2 import { generate } from '$lib/rule_generator';
3
4 const internals = {
5 ruleCount: 4
6 };
7
8 export const getRules = function () {
9
10 return readable([], function (set) {
11
12 (async function() {
13
14 const rules = [];
15 for (let i = 0; i < internals.ruleCount; ++i) {
16 rules.push(await generate());
17 }
18
19 set(rules.sort(() => Math.random() - 0.5));
20 })();
21
22 return function stop() {};
23 });
24 };