Skip to content

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

Merged
merged 18 commits into from
Nov 1, 2016
Merged

Support for joins #164

merged 18 commits into from
Nov 1, 2016

Conversation

morganchen12
Copy link
Contributor

@morganchen12 morganchen12 commented Oct 10, 2016

Mirrors firebase/FirebaseUI-Android#276.

Still missing a few things:

  • Documentation
  • Actual error handling
  • Data source tests
  • Tests for edge cases

Good to merge, pending some code review.

cc @puf, @ianbarber

@morganchen12 morganchen12 changed the base branch from master to v0.6.2 October 11, 2016 17:53
@morganchen12 morganchen12 reopened this Oct 11, 2016
@morganchen12 morganchen12 reopened this Oct 11, 2016
@morganchen12 morganchen12 force-pushed the joins branch 3 times, most recently from 7e2b1b6 to 8f19ca8 Compare October 12, 2016 17:44
/**
* A protocol to allow instances of FirebaseArray to raise events through a
* delegate. Raises all
* Firebase events except FIRDataEventTypeValue.
Copy link
Contributor

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

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

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

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.

Copy link
Contributor

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

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

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

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

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

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

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@morganchen12 morganchen12 force-pushed the joins branch 4 times, most recently from 808e654 to aa3a395 Compare October 14, 2016 17:00
@morganchen12 morganchen12 added this to the 1.0.0 milestone Oct 17, 2016
@morganchen12 morganchen12 force-pushed the joins branch 5 times, most recently from ac570ab to ed8267e Compare October 21, 2016 21:43
@morganchen12 morganchen12 changed the base branch from v0.6.2 to master October 21, 2016 21:46
@morganchen12
Copy link
Contributor Author

@ianbarber ready for more review

Copy link
Contributor

@ianbarber ianbarber left a 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
Copy link
Contributor

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@morganchen12 morganchen12 force-pushed the joins branch 2 times, most recently from bc1bb60 to f11270f Compare October 25, 2016 22:35
@morganchen12 morganchen12 changed the base branch from master to v1.0.0 November 1, 2016 23:08
@morganchen12 morganchen12 merged commit 596afb0 into firebase:v1.0.0 Nov 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants