Skip to content

feat(cloud_functions): add support for cloud functions stream #17214

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 39 commits into from
Apr 28, 2025

Conversation

SelaseKay
Copy link
Contributor

@SelaseKay SelaseKay commented Mar 20, 2025

Description

Replace this paragraph with a description of what this PR is doing. If you're modifying existing behavior, describe the existing behavior, how this PR is changing it, and what motivated the change.

Related Issues

Closes #17076

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@SelaseKay SelaseKay changed the title Feat/cloud functions stream support feat(cloud_functions): add support for cloud functions stream Mar 20, 2025
@@ -64,6 +64,7 @@ android {
implementation platform("com.google.firebase:firebase-bom:${getRootProjectExtOrCoreProperty("FirebaseSDKVersion", firebaseCoreProject)}")
implementation 'com.google.firebase:firebase-functions'
implementation 'androidx.annotation:annotation:1.7.0'
implementation 'org.reactivestreams:reactive-streams:1.0.4'
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why we would need an external library to handle this? We managed to do all the other implementations without it AFAIK/

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. The other ones provided a way to add listeners directly (eg. addOnConfigUpdatedListener) whereas this one doesn't. It returns a Publisher so this is the only way around it AFAIK.
Reference: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/functions/HttpsCallableReference#summary

final String eventChannelName = METHOD_CHANNEL_NAME + "/" + eventId;
final EventChannel eventChannel =
new EventChannel(pluginBinding.getBinaryMessenger(), eventChannelName);
eventChannel.setStreamHandler(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather have another class that implements EventChannel.StreamHandler so it's properly separated and easier to review

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I'll update the PR

@SelaseKay SelaseKay marked this pull request as ready for review April 3, 2025 12:42
@SelaseKay SelaseKay requested a review from Salakar as a code owner April 3, 2025 12:42
Copy link
Contributor

@Lyokone Lyokone left a comment

Choose a reason for hiding this comment

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

Doc and some nit.
The main thing missing are e2e tests

Really good job

@@ -0,0 +1,85 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry missed to catch this one in the last round

/// automatically includes a Firebase Instance ID token to identify the app
/// instance. If a user is logged in with Firebase Auth, an auth ID token for
/// the user is also automatically included.
Stream<StreamResponse> stream<T, R>([Object? input]) async* {
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the API doc, there's HttpsCallableStreamOptions as an optional parameter, but I don't find the code in this PR. Anything changed?

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, I had forgotten to update the documentation earlier. The original plan was to match the JS SDK’s stream signature, but we later decided to follow the native (Android/Java) convention instead. I’ve just updated the docs to reflect this change.

Copy link
Collaborator

@cynthiajoan cynthiajoan left a comment

Choose a reason for hiding this comment

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

Approved for API.

@Lyokone Lyokone merged commit 509e0f3 into main Apr 28, 2025
27 of 30 checks passed
@Lyokone Lyokone deleted the feat/cloud_functions_stream_support branch April 28, 2025 08:59
@victoire-hergan
Copy link

Wowwww thank you so much @SelaseKay and everyone else ;)

cynthiajoan added a commit that referenced this pull request May 8, 2025
* chore(ci): bump macos-14 to macos-15 (#17311)

* feat(cloud_functions): add support for cloud functions stream (#17214)

* chore: add platform interface and method channel implementation for Cloud Functions stream

* chore: add `httpsCallableStreamFromUrl` and `httpsStreamCallableWithUri`

* chore: resolve comments

* chore: add Android implementation for Cloud Functions stream

* chore: resolve formatting issues

* chore: correct variable name

* chore: add support for Cloud Functions Stream(Android)

* chore: create dedicated StreamHandler class

* chore: add streamhandler implementation for ios

* chore: add iOS implementation for Cloud Functions stream

* chore: add license header to stream handler files

* chore: web Cloud Functions stream wip

* chore: push all

* chore: update functions based on API Doc modification

* chore: clean up code

* chore: add web package

* chore: add streaming example

* chore: fix ci issues

* chore: fix ci

* chore: fix cloud function test

* chore: add missing doc

* chore: fixes and  clean up

* chore: add e2e for Cloud Functions Stream

* chore: fix formatting issue

* chore: add more tests and fix timeout for Android

* chore: add test for map and list

* chore: fix test

* chore: update year to 2025 in files

* chore(web): add support for abort signal

* chore: resolve comments and add test for Abort

* chore: fix test

* chore: fix test

* chore: update copyright year

* chore: print error to console

* chore(release): publish packages (#17314)

* chore(release): publish packages

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]+1

* chore: BoM Version 3.10.0

* constants

* fix(auth,apple): prevent EXC_BAD_ACCESS crash in Apple Sign-In completion handler (#17273)

- Locally captures completion handler to prevent deallocation
- Fixes crash during async Apple Sign-In operations

* chore(docs): Update Extension Helper Docs (#17327)

* feat(vertexai): Add HarmBlockThreshold.OFF (#17325)

* Add HarmBlockThreshold.OFF. Add unit test for api. Fix the schema output json.

* fix a nit

* feat(fdc): Included platform detection changes (#17308)

* feat(vertexai): Add responseModality (#17326)

* Add responseModality

* review comments

* handle omit tokenCount nicely (#17336)

* Add new attributes for schema (#17340)

* tweak after merge main

* fix analyzer for vertexai/api_test.dart

* remove dependency_overrides in pubspec.yaml

---------

Co-authored-by: MichaelV00 <[email protected]>
Co-authored-by: Jude Selase Kwashie <[email protected]>
Co-authored-by: Guillaume Bernos <[email protected]>
Co-authored-by: Luke Memet <[email protected]>
Co-authored-by: Maneesh Tewani <[email protected]>
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.

[cloud_functions] feature request for stream support
5 participants