working
This commit is contained in:
parent
8d143f4bf1
commit
1e2c26123b
3 changed files with 41 additions and 42 deletions
|
|
@ -139,17 +139,19 @@ export function Repl({ embedded = false }) {
|
|||
//
|
||||
|
||||
const handleTogglePlay = async () => editorRef.current?.toggle();
|
||||
const handleUpdate = async (newCode, reset = false) => {
|
||||
|
||||
// payload = {reset: boolean, code: string, evaluate: boolean}
|
||||
const handleUpdate = async ({ reset = false, code = null, evaluate = true }) => {
|
||||
if (reset) {
|
||||
clearCanvas();
|
||||
resetLoadedSounds();
|
||||
editorRef.current.repl.setCps(1);
|
||||
await prebake(); // declare default samples
|
||||
}
|
||||
if (newCode) {
|
||||
editorRef.current.setCode(newCode);
|
||||
editorRef.current.repl.evaluate(newCode);
|
||||
} else if (isDirty) {
|
||||
if (code != null) {
|
||||
editorRef.current.setCode(code);
|
||||
}
|
||||
if (evaluate && isDirty) {
|
||||
editorRef.current.evaluate();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue