-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(cloud_functions): add support for cloud functions stream #17214
base: main
Are you sure you want to change the base?
Conversation
packages/cloud_functions/cloud_functions/lib/src/firebase_functions.dart
Show resolved
Hide resolved
class MethodChannelHttpsCallableStreams<R> | ||
extends HttpsCallableStreamsPlatform<R> { | ||
MethodChannelHttpsCallableStreams(String? name, String? origin, Uri? uri) | ||
: _channel = EventChannel('plugins.flutter.io/firebase_functions/$name'), |
There was a problem hiding this comment.
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
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. &&
)
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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/
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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.///
).melos run analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?