Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@collinjackson
Copy link
Contributor

@collinjackson collinjackson commented May 31, 2017

@collinjackson collinjackson changed the title Improved API support for Firebase Database. WIP: Improved API support for Firebase Database. May 31, 2017
@eseidelGoogle
Copy link

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.

@collinjackson collinjackson changed the title WIP: Improved API support for Firebase Database. Improved API support for Firebase Database. Jun 5, 2017
@collinjackson
Copy link
Contributor Author

collinjackson commented Jun 5, 2017

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.

Copy link
Member

@goderbauer goderbauer left a 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":
{
Copy link
Member

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?

Copy link
Contributor Author

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.

@collinjackson collinjackson merged commit b7040ef into flutter:master Jun 5, 2017
@collinjackson collinjackson deleted the more_database branch June 5, 2017 19:29
Copy link
Contributor

@mravn-google mravn-google left a 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;
Copy link
Contributor

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");
Copy link
Contributor

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).
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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});
Copy link
Contributor

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().
Copy link
Contributor

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
Copy link
Contributor

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';
Copy link
Contributor

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.

@collinjackson
Copy link
Contributor Author

Thanks for the detailed feedback! I'll make these changes in a subsequent PR.

@collinjackson
Copy link
Contributor Author

Remaining code review feedback implemented in #144

julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants