Skip to content

[Do not merge] Support AsyncStream in realtime query #14924

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cherylEnkidu
Copy link
Contributor

No description provided.

Copy link
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

@google-oss-bot
Copy link

1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

let stream = query.asyncThrowingStream()
var iterator = stream.makeAsyncIterator()

let task = Task {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a Task here really needed?

I found doing it without Task and signalStream much easier to read:

https://github.com/firebase/firebase-ios-sdk/pull/14931/files#diff-c9933475816c94708983249c37c7ee449116ab4815fa96fb928113552f83c1eaR121

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the task is mainly used for testing the stream behaviour after the stream closed.

await signalStream.first { _ in true }

// 4. As soon as we receive the signal, we know it's safe to cancel.
task.cancel()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to verify the stream has been closed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, after the stream closed, the listener (iterator) will received nil

@cherylEnkidu cherylEnkidu force-pushed the cheryllin/AsyncFlowInRealtime branch from 98ad95d to 8c65663 Compare June 5, 2025 18:01
@cherylEnkidu cherylEnkidu assigned wu-hui and unassigned cherylEnkidu Jun 9, 2025
@cherylEnkidu cherylEnkidu changed the title Support AsyncStream in realtime query [Do not merge] Support AsyncStream in realtime query Jun 9, 2025

// 3. Wrap the asynchronous work in a Task.
let task = Task {
// Use a standard stream that stays open for new events.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think comments like this are too much, this is generated by Gemini I think?

Please reduce the number of comments and only leave those that are the key steps of the tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback on the comments. My intention was to add clarity to the asynchronous test flow, as these can sometimes be less straightforward to follow than synchronous tests. However, I agree that excessive comments can clutter the code and that focusing on the key steps is a better approach for test readability. I will update the comments to be more concise and highlight only the essential parts of the test setup and execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants