-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delayed asynchronous code features #25
Comments
Hey this looks like a question that you'd want to ask in discussion but anyway to answer your question, you can always use Promise in order to make your code execute asynchronously, here's how you can do so. const myFunc = async () => {
console.log("before timeout");
await new Promise((resolve) => {
setTimeout(resolve, 2000);
});
console.log("after timeout");
}
myFunc(); This code, in simple words, pauses execution for 2 seconds before moving on. You can read more on async-await and promises here. Please close this issue if your query is answered. |
Sorry, this doesn't answer my question. I know it will pause the execution for specified time, but what i'm asking for the feature is on displaying the code that is not delayed first, and then after that specified time, it execute the code inside asynchronous code. |
In your code example, "before timeout" will displayed at the same time with the code inside I'm hoping there will be a indicator in the response if the code finally executed, still executed, or error when executing. For example {
"timestamp": 16792938484,
"status": 200,
"output": "still executing the asynchronous code",
"error": "",
"language": "js",
"info": "v16",
"compilerStatus": "onProgress"
} And then when the async code finishes, will display different response {
"timestamp": 16792938484,
"status": 200,
"output": "this output is from async code",
"error": "",
"language": "js",
"info": "v16",
"compilerStatus": "onFinished"
} I'm taking this inspiration from AssemblyAI on how they give a key You could make this the same if you 're giving each request an |
In javascript, if there's a line that causing errors, it still execute the code anyway. console.log("this is working code");
console.log("this is error code); The output will be this is working code
SyntaxError: error messages here... |
This is a good feature idea, you can work on this if you want to, cause I got exams next week and can't promise to get it up and working soon. |
Sorry for long response, i dont have docker installed yet. Currently i'm trying to resolve this problem. It seems you split it only by |
Is there a way to work with asynchronous code that have delay? For example,
setTimeout()
in javascript.If i made a code inside the timeout and make the delay to be 2 seconds, all of the code just executed. Here is example code
The text was updated successfully, but these errors were encountered: