-
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
Merged
Merged
Support for joins #164
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ad34bc7
support for joins
morganchen12 6cf9769
clean up whitespace
morganchen12 68d52cd
clean up nullability
morganchen12 43a9247
add data source classes
morganchen12 625a774
clean up FirebaseIndexArray
morganchen12 c3d0abd
implement delegate methods, add doc comments
morganchen12 9b26087
fix uninitialized variable in block capture
morganchen12 84880a1
implement error handling methods for indexed data sources
morganchen12 6ad8a89
add FirebaseIndexTableViewDataSourceTests
morganchen12 6628abd
add FirebaseIndexCollectionViewDataSourceTest
morganchen12 09045ac
fix bad links in doc comments
morganchen12 5b3d50d
update doc comments
morganchen12 9b8c842
simplify object ownership graph and update doc comments
morganchen12 90bf0c4
add tests for index array delegate, edge cases
morganchen12 f79764a
disable documentation warnings, fix some docs issues
morganchen12 1906314
fix up doc comments
morganchen12 0543fa7
fix tests not loading dylibs correctly
morganchen12 8619311
remove cell creation from data sources
morganchen12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
// clang-format off | ||
|
||
// | ||
// Copyright (c) 2016 Google Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
// clang-format on | ||
|
||
#import "FirebaseArray.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@class FirebaseIndexArray; | ||
|
||
/** | ||
* A protocol to allow instances of FirebaseIndexArray to raise events through a | ||
* delegate. Raises all Firebase events except @c FIRDataEventTypeValue. | ||
*/ | ||
@protocol FirebaseIndexArrayDelegate <NSObject> | ||
|
||
@optional | ||
|
||
/** | ||
* Delegate method called when the database reference at an index has | ||
* finished loading its contents. | ||
* @param array The array containing the reference. | ||
* @param ref The reference that was loaded. | ||
* @param object The database reference's contents. | ||
* @param index The index of the reference that was loaded. | ||
*/ | ||
- (void)array:(FirebaseIndexArray *)array | ||
reference:(FIRDatabaseReference *)ref | ||
didLoadObject:(FIRDataSnapshot *)object | ||
atIndex:(NSUInteger)index; | ||
|
||
/** | ||
* Delegate method called when the database reference at an index has | ||
* failed to load contents. | ||
* @param array The array containing the reference. | ||
* @param ref The reference that failed to load. | ||
* @param index The index in the array of the reference that failed to load. | ||
* @param error The error that occurred. | ||
*/ | ||
- (void)array:(FirebaseIndexArray *)array | ||
reference:(FIRDatabaseReference *)ref | ||
atIndex:(NSUInteger)index | ||
didFailLoadWithError:(NSError *)error; | ||
|
||
/** | ||
* Delegate method which is called whenever an object is added to a | ||
* FirebaseArray. On a FirebaseArray synchronized to a Firebase reference, | ||
* this corresponds to a @c FIRDataEventTypeChildAdded event being raised. | ||
* @param ref The database reference added to the array | ||
* @param index The index the reference was added at | ||
*/ | ||
- (void)array:(FirebaseIndexArray *)array didAddReference:(FIRDatabaseReference *)ref atIndex:(NSUInteger)index; | ||
|
||
/** | ||
* Delegate method which is called whenever an object is changed in a | ||
* FirebaseArray. On a FirebaseArray synchronized to a Firebase reference, | ||
* this corresponds to a @c FIRDataEventTypeChildChanged event being raised. | ||
* @param ref The database reference that changed in the array | ||
* @param index The index the reference was changed at | ||
*/ | ||
- (void)array:(FirebaseIndexArray *)array didChangeReference:(FIRDatabaseReference *)ref atIndex:(NSUInteger)index; | ||
|
||
/** | ||
* Delegate method which is called whenever an object is removed from a | ||
* FirebaseArray. On a FirebaseArray synchronized to a Firebase reference, | ||
* this corresponds to a @c FIRDataEventTypeChildRemoved event being raised. | ||
* @param ref The database reference removed from the array | ||
* @param index The index the reference was removed at | ||
*/ | ||
- (void)array:(FirebaseIndexArray *)array didRemoveReference:(FIRDatabaseReference *)ref atIndex:(NSUInteger)index; | ||
|
||
/** | ||
* Delegate method which is called whenever an object is moved within a | ||
* FirebaseArray. On a FirebaseArray synchronized to a Firebase reference, | ||
* this corresponds to a @c FIRDataEventTypeChildMoved event being raised. | ||
* @param ref The database reference that has moved locations | ||
* @param fromIndex The index the reference is being moved from | ||
* @param toIndex The index the reference is being moved to | ||
*/ | ||
- (void)array:(FirebaseIndexArray *)array didMoveReference:(FIRDatabaseReference *)ref fromIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex; | ||
|
||
/** | ||
* 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 | ||
* (i.e. by displaying a modal error explaining why there's no content). | ||
* @param error the error that was raised | ||
*/ | ||
- (void)array:(FirebaseIndexArray *)array queryCancelledWithError:(NSError *)error; | ||
|
||
@end | ||
|
||
/** | ||
* A FirebaseIndexArray instance uses a query's contents to query children of | ||
* a separate database reference, which is useful for displaying an indexed list | ||
* of data as described in https://firebase.google.com/docs/database/ios/structure-data | ||
*/ | ||
@interface FirebaseIndexArray : NSObject | ||
|
||
/** | ||
* An immutable copy of the loaded contents in the array. Returns an | ||
* empty array if no contents have loaded yet. | ||
*/ | ||
@property(nonatomic, copy, readonly) NSArray<FIRDataSnapshot *> *items; | ||
|
||
/** | ||
* The delegate that this array should forward events to. | ||
*/ | ||
@property(nonatomic, weak) id<FirebaseIndexArrayDelegate> delegate; | ||
|
||
/** | ||
* Returns the number of items in the array. | ||
*/ | ||
@property(nonatomic, readonly) NSUInteger count; | ||
|
||
- (instancetype)init NS_UNAVAILABLE; | ||
|
||
/** | ||
* Initializes a FirebaseIndexArray with an index query and a data query. | ||
* The array expects the keys of the children of the index query to match exactly children | ||
* of the data query. | ||
* @param index A Firebase database query whose childrens' keys are all children | ||
* of the data query. | ||
* @param data A Firebase database reference whose children will be fetched and used | ||
* to populate the array's contents according to the index query. | ||
* @param delegate The delegate that events should be forwarded to. | ||
*/ | ||
- (instancetype)initWithIndex:(id<FIRDataObservable>)index | ||
data:(id<FIRDataObservable>)data | ||
delegate:(nullable id<FirebaseIndexArrayDelegate>)delegate NS_DESIGNATED_INITIALIZER; | ||
|
||
/** | ||
* 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 | ||
* of the data query. | ||
* @param index A Firebase database query whose childrens' keys are all children | ||
* of the data query. | ||
* @param data A Firebase database reference whose children will be fetched and used | ||
* to populate the array's contents according to the index query. | ||
*/ | ||
- (instancetype)initWithIndex:(id<FIRDataObservable>)index | ||
data:(id<FIRDataObservable>)data; | ||
|
||
/** | ||
* Returns the snapshot at the given index, if it has loaded. | ||
* Raises a fatal error if the index is out of bounds. | ||
* @param index The index of the requested snapshot. | ||
* @return A snapshot, or nil if one has not yet been loaded. | ||
*/ | ||
- (nullable FIRDataSnapshot *)objectAtIndex:(NSUInteger)index; | ||
|
||
/** | ||
* Removes all observers from all queries managed by this array and renders this array | ||
* unusable. | ||
*/ | ||
- (void)invalidate; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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