-
Notifications
You must be signed in to change notification settings - Fork 483
Support for joins #164
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
Support for joins #164
Conversation
7e2b1b6
to
8f19ca8
Compare
/** | ||
* A protocol to allow instances of FirebaseArray to raise events through a | ||
* delegate. Raises all | ||
* Firebase events except FIRDataEventTypeValue. |
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: weird line split
* Delegate method which is called whenever an object is added to a | ||
* FirebaseArray. On a | ||
* FirebaseArray synchronized to a Firebase reference, this corresponds to an | ||
* [FIRDataEventTypeChildAdded](https://www.firebase.com/docs/ios/guide/retrieving-data.html#section-event-types) |
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.
Please replace these doc links with ones to firebase.google.com across the file
|
||
/** | ||
* Delegate method which is called whenever the backing query is canceled. This error is fatal | ||
* and the index array will become unusable afterward, so please handle it appropriately. |
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.
What is the appropriate handling? Guessing effectively to stop using this object
|
||
@interface FirebaseIndexArray () <FirebaseArrayDelegate> | ||
|
||
@property (nonatomic, readonly) id<FIRDataObservable> index; |
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.
Not a big fan of the readonly here - if we're declaring private property decls lets make them readwrite and use self.property when setting.
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.
Note: discussed this separately, so either way works as long as consistent.
NSParameterAssert(data != nil); | ||
self = [super init]; | ||
if (self != nil) { | ||
_index = index; |
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.
as with comment above, would prefer self.index
} | ||
|
||
- (NSUInteger)count { | ||
return self.observers.count; |
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.
while here _observers.count would be fine
#pragma mark - FirebaseArrayDelegate | ||
|
||
// These delegate methods are entirely responsible | ||
// for keeping a local array of queries up to date. |
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 comment is a bit abandoned here. I might be inclined to move it into a top level class comment that explains what we are trying to do and how we go about it.
|
||
@end | ||
|
||
@interface FirebaseIndexArray : NSObject |
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 needs a decent class comment explaining what this is for and how it should be used
|
||
@end | ||
|
||
@implementation FirebaseIndexArray |
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.
Add class comment about any implementation level details (see comment below)
- (instancetype)initWithIndex:(id<FIRDataObservable>)index | ||
data:(id<FIRDataObservable>)data | ||
delegate:(nullable id<FirebaseIndexArrayDelegate>)delegate; { | ||
NSParameterAssert(index != nil); |
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.
As discussed, see whether replacing one firebasearray with a query makes the code easier.
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 tried this and ended up duplicating much of the index
logic since queries only give you the previousChildKey
. Might be worth extracting that from FirebaseArray into a more inert data object, but for now I think keeping FirebaseArray here is cleaner, if not less verbose.
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.
ack
808e654
to
aa3a395
Compare
ac570ab
to
ed8267e
Compare
@ianbarber ready for more 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.
LGTM, couple of small comment nits.
* [FIRDataEventTypeChildAdded](https://www.firebase.com/docs/ios/guide/retrieving-data.html#section-event-types) | ||
* event being raised. | ||
* FirebaseArray. On a FirebaseArray synchronized to a Firebase reference, | ||
* this corresponds to a @c FIRDataEventTypeChildAdded event being raised. | ||
* @param object The object added to the FirebaseArray | ||
* @param index The index the child was added at | ||
*/ | ||
- (void)array:(FirebaseArray *)array didAddObject:(id)object atIndex:(NSUInteger)index; | ||
|
||
/** | ||
* Delegate method which is called whenever an object is chinged in a |
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.
Not your fault but chinged -> changed
|
||
/** | ||
* Initializes a FirebaseIndexArray with an index query and a data query. | ||
* The array expects the keys of the children of the index query to be children |
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.
(here and elsewhere) change "to be" to "to match" - this is complex stuff, and clarifying that we have the same values in two places is probably pertinent.
- (instancetype)initWithIndex:(id<FIRDataObservable>)index | ||
data:(id<FIRDataObservable>)data | ||
delegate:(nullable id<FirebaseIndexArrayDelegate>)delegate; { | ||
NSParameterAssert(index != nil); |
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.
ack
bc1bb60
to
f11270f
Compare
Mirrors firebase/FirebaseUI-Android#276.
Still missing a few things:DocumentationActual error handlingData source testsTests for edge casesGood to merge, pending some code review.
cc @puf, @ianbarber