reset cps before eval
This commit is contained in:
parent
f8724bf47e
commit
436ba067bc
1 changed files with 11 additions and 0 deletions
|
|
@ -42,6 +42,17 @@ export function repl({
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
beforeEval?.({ code });
|
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
|
||||||
|
// example:
|
||||||
|
/*
|
||||||
|
await new Promise(resolve => setTimeout(resolve,1000))
|
||||||
|
setCps(.5)
|
||||||
|
note("c a f e")
|
||||||
|
*/
|
||||||
|
// to make sure the setCps inside the code is called immediately,
|
||||||
|
// it has to be placed first
|
||||||
let { pattern } = await _evaluate(code, transpiler);
|
let { pattern } = await _evaluate(code, transpiler);
|
||||||
|
|
||||||
logger(`[eval] code updated`);
|
logger(`[eval] code updated`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue