Skip to content

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.

2 participants