Skip to content
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

feat(client): subscribe to status #76

Merged
merged 2 commits into from
Jul 23, 2024
Merged

Conversation

drochetti
Copy link
Collaborator

subscribeToStatus API

The fal.queue.subscribeToStatus(endpointId, options) exposes the polling (or streaming) mechanism used by fal.subscribe(endpointId, options) as an API so that users can use to manage more complex workflows, such as client/server integration.

See #59 for feature request and use case details.

How to use it

After calling fal.queue.submit() or have obtained a requestId submitted to fal some other way (e.g. in your server), call fal.queue.subscribeToStatus() to listen to queue status updates until it's done:

const { requestId } = await fal.queue.submit("my/endpoint");

await fal.queue.subscribeToStatus("my/endpoint", {
  requestId,
  onQueueUpdate(update) {
    console.log(update.status);
  }
});

//  it's all done, you can fetch the result now
const result = await fal.queue.result("my/endpoint", { requestId });

@drochetti drochetti merged commit d9ea6c7 into main Jul 23, 2024
1 check passed
@drochetti drochetti deleted the feat/queue-subscribe-to-status branch October 1, 2024 21:44
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