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(cloud_functions): add support for cloud functions stream #17214

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

SelaseKay
Copy link
Contributor

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

Replace this paragraph with a list of issues related to this PR from the issue database. Indicate, which of these issues are resolved or fixed by this PR. Note that you'll have to prefix the issue numbers with flutter/flutter#.

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
class MethodChannelHttpsCallableStreams<R>
extends HttpsCallableStreamsPlatform<R> {
MethodChannelHttpsCallableStreams(String? name, String? origin, Uri? uri)
: _channel = EventChannel('plugins.flutter.io/firebase_functions/$name'),
Copy link
Member

Choose a reason for hiding this comment

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

you have name as first argument but it should probably be origin. You are passing in origin as first arg here: https://github.com/firebase/flutterfire/pull/17214/files#diff-39179fb42585c5c75b6cfd6b3e5cd34e92705b1df98759afa825ef6ccadeb4eeR57

and here: https://github.com/firebase/flutterfire/pull/17214/files#diff-39179fb42585c5c75b6cfd6b3e5cd34e92705b1df98759afa825ef6ccadeb4eeR62

Need to do an assert here as name could be null. If name and uri are null, need to throw assertion error. The last segment of event channel name should be either name or uri depending on what is not null. Double check if there are any characters that could be a problem in event channel name as a uri might not be possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The assertion is already handled on the parent(HttpsCallableStreamsPlatform) class: here

Copy link
Member

Choose a reason for hiding this comment

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

Wonderful, is the assertion correct? Shouldn't it be if both are null? (i.e. &&)

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, at any given time, one of the two variables will be set, depending on which method was called: httpsStreamCallable or httpsStreamCallableWithUri.

@@ -1,2 +1,2 @@
# https://firebase.google.com/support/release-notes/android
FirebaseSDKVersion=33.9.0
FirebaseSDKVersion=33.11.0
Copy link
Member

Choose a reason for hiding this comment

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

do this in a separate PR for bumping android SDK

@@ -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

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.

3 participants