-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Improved API support for Firebase Database. #89
Conversation
|
Some of @lukef and @KevinTheGray's firebase work is believed to be blocked on this. :) They're considering pushing off firebase work for a week if this needs more time to bake. Just checking in. |
a1c3a9a to
bd43dbc
Compare
bd43dbc to
d6e204f
Compare
|
Most of the database code I've been working on has been Database UI improvements (fixes flutter/flutter#10439) and an improved example app. I'd like another day or so to test those more prior to landing. Based on flutter/flutter#10411 and flutter/flutter#10421 it sounds like @lukef and@KevinTheGray mostly just need the core database additions. So I'm punting all the UI changes and example app into a separate PR and this PR is now just about adding the missing APIs (including tests). I think this can land as soon as I get an LGTM on it. |
d6e204f to
697c4d8
Compare
goderbauer
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.
LGTM
| Map<String, Object> arguments = (Map<String, Object>) call.arguments; | ||
| switch (call.method) { | ||
| case "FirebaseDatabase#goOnline": | ||
| { |
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.
Does this need to be in a block?
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.
It doesn't, I was trying to be consistent with the others but maybe it's better not to do a block. I've removed the braces for the methods that don't take arguments.
1f5fad8 to
dcb1a18
Compare
mravn-google
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.
LGTM, mostly nits
| reference.removeEventListener((ValueEventListener) observer); | ||
| } else { | ||
| reference.removeEventListener((ChildEventListener) observer); | ||
| Map<String, Object> arguments = (Map<String, Object>) 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.
To avoid the unchecked cast warning, do
Map<String, Object> arguments = call.arguments();|
|
||
| case "FirebaseDatabase#setPersistenceEnabled": | ||
| { | ||
| boolean isEnabled = (boolean) arguments.get("enabled"); |
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.
[nit] You can avoid cast with
Boolean isEnabled = arguments.get("enabled");Similarly below.
| /// priority (including no priority), they are sorted by key. Numeric keys | ||
| /// come first (sorted numerically), followed by the remaining keys (sorted | ||
| /// lexicographically). | ||
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.
Missing /// here?
| /// Note that priorities are parsed and ordered as IEEE 754 double-precision | ||
| /// floating-point numbers. Keys are always stored as strings and are treated | ||
| /// as numbers only when they can be parsed as a 32-bit integer |
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.
[nit] Missing . at the end.
| /// operations when the network connection is restored. | ||
| /// | ||
| /// However by default your write operations and cached data are only stored | ||
| /// in-memory and will be lost when your app restarts. By setting this value |
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 value to YES => [enabled] to true
| return _channel.invokeMethod("FirebaseDatabase#goOnline"); | ||
| } | ||
|
|
||
| /// Shuts down our connection to the Firebase Database backend until goOnline |
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.
[goOnline]
| /// than or equal to the given key. | ||
| Query endAt(dynamic value, { String key }) { | ||
| assert(!_parameters.containsKey('endAt')); | ||
| return _copyWithParameters({ 'endAt': value, 'endAtKey': key}); |
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.
[nit] Missing space before }
|
|
||
| /// Generate a view of the data sorted by values of a particular child key. | ||
| /// | ||
| /// Intended to be used in combination with startAt(), endAt(), or equalTo(). |
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.
[startAt()], [endAt()], [equalTo()]
More places below
| }); | ||
| } | ||
|
|
||
| class MockPlatformChannel extends Mock implements MethodChannel { } 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.
Remove this?
And maybe end the file with a new-line.
|
|
||
| import 'dart:async'; | ||
|
|
||
| import 'package:mockito/mockito.dart'; |
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.
Are you using mockito for anything? Seems your mock channel isn't used.
|
Thanks for the detailed feedback! I'll make these changes in a subsequent PR. |
|
Remaining code review feedback implemented in #144 |
Improved API support for Firebase Database for 0.0.6 * Various APIs added to FirebaseDatabase and Query * Added removal and priority to DatabaseReference * Improved documentation * Added unit tests
Fixes flutter/flutter#10411
Fixes flutter/flutter#10421