Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit68a0844

Browse files
committed
Interrupt and await already running code before running again.
1 parent5f8dbb1 commit68a0844

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎frontend/src/RunCode.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,16 @@ function inputCallback(messageId) {
6464
exportletinterrupt=()=>{
6565
};
6666

67+
letfinishedLastRun=Promise.resolve();
68+
letfinishedLastRunResolve;
69+
6770
exportconstrunCode=async({code, source})=>{
71+
if(bookState.running){
72+
interrupt();
73+
awaitfinishedLastRun;
74+
}
75+
finishedLastRun=newPromise(r=>finishedLastRunResolve=r);
76+
6877
constshell=source==="shell";
6978
if(shell){
7079
if(awaitingInput){
@@ -206,6 +215,8 @@ export const runCode = async ({code, source}) => {
206215
terminalRef.current.focusTerminal();
207216
}
208217

218+
finishedLastRunResolve();
219+
209220
if(isProduction){
210221
databaseRequest("POST",{
211222
entry,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp