-
Notifications
You must be signed in to change notification settings - Fork 485
Added support for using NSSort Descriptors & NSPredicate & Sections #12
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
Conversation
…ults client-side.
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
@pmodernme awesome! I just gave it a glance and it looks pretty good 👍 I'll give it a more thorough review later this week. A few initial thoughts:
Also, if you'd like to do some Java, we can get close to feature parity on the Android version by implementing custom comparators for sorting and then using something like Guava for predicate support. |
Hi Michael. Thanks for all the feedback. I really appreciate it.
FirebaseTableViewDataSource * datasource = [FirebaseTableViewDataSource And then maybe setting the ref activates it, or if the user calls
I haven't programmed in Java in a decade, so I can't help much there. If my I'm currently attempting to implement sectioning. I'm going to work on it a bit more --Zoe |
CLAs look good, thanks! |
FirebaseArray now uses NSIndexPaths.
@mcdonamp I added sectioning. It works pretty slowly for large datasets (over 200 snapshots). I eliminated most of the begin / endUpdates calls. The data also appears more uniformly at initial display. Any thoughts on thread safety? It would be nice to be able to put Firebase on a background thread and still play nice with UIKit. |
Can we split out sectioning into it's own PR? It'll be easier to pull them in independently (even if the sectioning PR is pending this one). The hard part about threading is that all UI updates have to happen on the main thread, so even if we're able to raise events in the background (which we already are, I believe), it might not have a significant impact. I'll poke around and see though. The "large" datasets problem is likely to still exist, and the short answer is that we might have to do end up querying things and doing a paginated approach (though Firebase doesn't have great support for that yet). |
This is good stuff, but hasn't been talked about in a while. Will this still be merged in? |
I'm in need of something like this as well. I was about to implement something when I decided to come take a look at the issues list. I think @pmodernme's implementation is a better, more generic approach to what I was going to do. I forked master and took a look at what it would take to merge her changes, which were based on 0.4, and it's quite a lot. At this point, her work seems to be far enough away that someone would need to reimplement support for Sorting, Filtering, and Sections just using her implementation as a guide. Is anyone looking into this? 1) I might not have the skill to do it. I've been working in Swift now for over a year. 2) I don't want to invest the time if a Pull Request is just going to be allowed to die. 3) I might be forced to hack something more concrete for my use case due to time constraints on my side. Thoughts? |
@chadpav the changes were actually based on 0.3 (or maybe even 0.2), so quite a bit has changed--and yes, it's likely that it would need to be mostly re-implemented. The short answer about how we evaluate PRs is basically twofold:
Usually, the former is fulfilled, and the latter isn't. The former is important because we don't want to create a poor experience for Firebase apps by providing bad implementations of things like Auth, or client side merging (an inefficient implementation might render in a less than realtime way, which is generally our concern for things like this. That said, it hasn't stopped us in the past, see firebase-util and QueryBase. The latter is important because Firebase is cross platform, and we need a consistent feature set in FirebaseUI to assure that all platforms are equally powerful and easy to use. This is much harder in the open source community since typically people aren't willing/able to do two or three implementations of a feature, and we haven't done the best job of trying to coordinate community resources. I've been mulling a re-write of the internals here, and it's been brought up by a few colleagues after firebase/FirebaseUI-Android#276 to build this feature in ( |
@mcdonamp, that's a great response. I appreciate it. You guys have a high bar for community contributions but they do make sense. As you assume, it's going to be too high for an individual contributor on a single platform to meet though. It would be nice to document some of this discussion in the "Contributing to FirebaseUI" section of the README across all relevant platforms. Currently it sounds much more straight forward than what we are discussing here. I trust that if you see an Issue or Pull Request in this repo that it makes it to the right person to evaluate whether or not the request should be prioritized across all relevant platforms. Thanks so much! There are a lot of really nice things about Firebase that I'm enjoying. |
@chadpav not a problem. We had this discussion a few months back, and it resulted in adding such language to the PR template on both platforms. I totally agree that we should add it to the respective contributing sections as well, since folks won't realize until after they've put in the effort that something may not exist. That being said, because things are open source, developers are always welcome to have additional use case specific features on their own forks :) The overall goal is to make this project more transparent. We've started moving issues (including our roadmap) into the issue tracker, and are trying to put together practices that allow community members to grab bugs and work on them with the guarantee that as long as they meet the quality bar, they'll be accepted (since by being prioritized and mentioned as ready for work, they should be meet our contribution standards). If you have suggestions on how to best approach this (or things that would help you contribute), we're all ears. |
@chadpav I've added relevant language to iOS and Android CONTRIBUTING.md, let me know if this covers what you're thinking. |
@mcdonamp These are the changes I mentioned in my Issue I sent you Friday.
NSSortDescriptor
s are used in theFirebaseArray
to sort the results client-side. When using this method, it is most useful to useFQuery
for initially filtering results, not sorting them.e.g.:
[[ref queryOrderedByChild:@"hidden"] queryEqualToValue:@NO];
Then add the
NSSortDescriptor
to the firebase array when initializing your data source.[[NSSortDescriptor alloc] initWithKey:@"value.origin_date" ascending:NO]]
NSSortDescriptors
are added as an array. Results are sorted first by thesortDescriptor
at index 0, then index 1, etc...You can add an
NSPredicate
to theFirebaseArray
to filter the results on the client-side.Both
NSSortDescriptor
s andNSPredicate
filter based on theFDataSnapshots
received by the Array.