Skip to content

Add abort signal option to run method and stop callback to wait method #106

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

Merged
merged 2 commits into from
Jul 28, 2023

Conversation

mattt
Copy link
Contributor

@mattt mattt commented Jul 28, 2023

The AbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired.

This PR adds a signal option to the run method. Normally, the run method creates a prediction and then waits until it finishes. Because it doesn't return an intermediate value (unlike predictions.create), there's no mechanism for stopping and canceling the prediction until after it's completed.

This PR also adds a stop parameter to the wait method, which is used in the implementation of the abort signal. With this change, you can now pass a function as an argument to wait that takes a prediction as an argument and returns a promise for a Boolean. If this callback returns true, then the wait stops polling and returns. This callback also provides a way to monitor progress as the predictions updates.

@mattt mattt merged commit fbc3bf2 into main Jul 28, 2023
@mattt mattt deleted the mattt/abort-signal branch July 28, 2023 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant