-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[WIP] Federated cloud firestore platform interface #1568
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
[WIP] Federated cloud firestore platform interface #1568
Conversation
|
(Force-pushed after rebasing with the latest master) |
…napshots' This is to prevent naming collisions with the same method from Document References.
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 have one high level concern about how we're structuring the platform interface (see below) and some style nits that apply throughout this PR:
Use a trailing comma for arguments, parameters, and list items, but only if they each have their own line.
Example:
List<int> myList = [
1,
2,
];
myList = <int>[3, 4];
foo1(
bar,
baz,
);
foo2(bar, baz);
Only use => when everything, including the function declaration, fits on a single line.
| @@ -0,0 +1 @@ | |||
| {"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"cloud_firestore","dependencies":["firebase_core"]},{"name":"firebase_core","dependencies":[]}]} No newline at end of file | |||
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.
Should not be checked in to version control
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 have no idea where this is coming from; I'll remove it from the PR, and add it to .gitignore
packages/cloud_firestore/cloud_firestore/lib/src/document_reference.dart
Outdated
Show resolved
Hide resolved
packages/cloud_firestore/cloud_firestore/lib/src/document_reference.dart
Outdated
Show resolved
Hide resolved
packages/cloud_firestore/cloud_firestore/lib/src/document_reference.dart
Outdated
Show resolved
Hide resolved
| /// You can get an instance by calling [Firestore.instance]. | ||
| class Firestore { | ||
| Firestore({FirebaseApp app}) : app = app ?? FirebaseApp.instance { | ||
| if (_initialized) return; |
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.
This can be removed now.
...oud_firestore/cloud_firestore_platform_interface/lib/src/method_channel_cloud_firestore.dart
Outdated
Show resolved
Hide resolved
...oud_firestore/cloud_firestore_platform_interface/lib/src/method_channel_cloud_firestore.dart
Outdated
Show resolved
Hide resolved
...oud_firestore/cloud_firestore_platform_interface/lib/src/method_channel_cloud_firestore.dart
Outdated
Show resolved
Hide resolved
...oud_firestore/cloud_firestore_platform_interface/lib/src/method_channel_cloud_firestore.dart
Outdated
Show resolved
Hide resolved
| TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
|
||
| group('$MethodChannelCloudFirestore', () { | ||
| final MethodChannelCloudFirestore channelPlatform = |
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.
Lots more to write 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.
Indeed 😭
…s stream. (Corrected return type of Stream controller for the Query snapshots as well)
| } | ||
|
|
||
| // Document Reference | ||
| Future<void> setDocumentReferenceData( |
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.
@amirh Does this seem right to you as a style convention for federated plugins that are wrapping instances of native classes other than the main class of the plugin?
Right now we're shoehorning everything onto CloudFirestorePlatform instead of having a PlatformDocumentReference that has the same extends-only semantics as CloudFirestorePlatform.
If we were ok with being less idiomatically Dart we could call it something like DocumentReference_setData... not sure that's actually better but I just want to make sure that we're ok with the pattern being established 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.
I think it's definitely makes sense for the platform interface to be composed from multiple classes. In fact we've already done this in the webview plugin (WebViewPlatform and WebViewPlatformController). I think it's less of a convention thing and more of a "whatever design works fits better for a given plugin".
For this case, after discussing with Collin, it seems like multiple classes is a better choice.
collinjackson
left a comment
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.
|
|
||
| void _handleDocumentSnapshot(MethodCall call) { | ||
| final int handle = call.arguments['handle']; | ||
| _queryObservers[handle].add(call.arguments); |
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.
_queryObservers should be _documentObservers, right?
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.
Yep, good catch!
| ); | ||
| } | ||
|
|
||
| static final Map<int, StreamController<int>> _documentObservers = |
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.
Map should be Map<int, StreamController<dynamic>>
| ); | ||
| } | ||
|
|
||
| static final Map<int, StreamController<int>> _queryObservers = |
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.
Map should be Map<int, StreamController<dynamic>>
|
(I'm going to close this, so no more effort is wasted here. Apologies @andrea689, I'll keep your reviews in mind in my next iteration of this! And thanks again!) |
Description
WIP the platform interface + native plugin changes for cloud_firestore federation.
Many things missing, chief of which are: