improve initial loading + wait before eval

This commit is contained in:
Felix Roos 2023-03-23 21:56:20 +01:00
parent d17543d5d9
commit 55c533c947
3 changed files with 13 additions and 7 deletions

View file

@ -41,7 +41,7 @@ export function repl({
throw new Error('no code to evaluate');
}
try {
beforeEval?.({ code });
await beforeEval?.({ code });
scheduler.setCps(1); // reset cps in case the code does not contain a setCps call
// problem: when the code does contain a setCps after an awaited promise,
// the cps will be 1 until the promise resolves

View file

@ -46,9 +46,9 @@ function useStrudel({
drawContext,
transpiler,
editPattern,
beforeEval: ({ code }) => {
beforeEval: async ({ code }) => {
setCode(code);
beforeEval?.();
await beforeEval?.();
},
afterEval: (res) => {
const { pattern: _pattern, code } = res;