-
-
Notifications
You must be signed in to change notification settings - Fork 570
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
Possible cancel of command promises #940
Labels
Comments
The abort signal should be exposed with an API: terminal::signal() So the user can use it with $('body').terminal(async function(command) {
const signal = this.signal();
const res = await fetch('./api?' + command, { signal });
if (!signal.aborted) {
const json = await res.json();
this.echo(json.result);
}
}); |
|
jcubic
added a commit
that referenced
this issue
Sep 5, 2024
The new API:
both return signals that can be aborted with CTRL+D in addition the timeout aborts as name suggest after a timeout. There is also a method:
option:
Example usage: $('body').terminal(async () => {
const signal = this.timeout(500);
const res = await fetch('./api?command=' + encodeURIComponent(command), { signal });
const json = await res.json();
this.echo(json.result);
}); |
jcubic
added
the
resolved
if issue is resolved, it will be open until merge with master
label
Sep 6, 2024
jcubic
added a commit
that referenced
this issue
Sep 6, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
I have an idea for a new feature for jQuery Terminal
In this article are examples of using AbortController to cancel promises (by wrapping them and not resolving when there was an abort signal)
How To Cancel Any Async Task in JavaScript
This could be incorporated with the code for CTRL+D the old code with $.ajax can be removed, and replaced with handler for all promises.
The text was updated successfully, but these errors were encountered: