spf2 / FirebaseAdapter

Swift UI toolkit that makes building scalable Firebase UIKit applications easier.
MIT License
9 stars 0 forks source link

Generate sections from keypath? #1

Open kermankohli opened 9 years ago

kermankohli commented 9 years ago

Hey not sure if you can do this, but is it possible to create sections from values inside an object? Like NSFetchedResultsController's sectionKeyPath property?

spf2 commented 9 years ago

Hi - So I think what your asking is for something like PartitionedStream, but where the section names and number of sections isn't know in advance in the code, but rather is derived from the data. Is that right?

kermankohli commented 9 years ago

Yeap, that's it :) 

— Sent from Mailbox

On Wed, Nov 11, 2015 at 9:55 AM, spf2 notifications@github.com wrote:

Hi - So I think what your asking is for something like PartitionedStream, but where the section names and number of sections isn't know in advance in the code, but rather is derived from the data. Is that right?

Reply to this email directly or view it on GitHub: https://github.com/spf2/FirebaseAdapter/issues/1#issuecomment-155562885

spf2 commented 9 years ago

I see. Well, it's not possible as the code is currently written, but might not be too hard to add. I guess I'd want to change PartitionedStream to use a partition function that can return section names based on items, rather than just return the section number.

By the way, what are the properties you want to use as sections? How would they be sorted? I suppose we'd also need a way to specify the sort order of the sections...

kermankohli commented 9 years ago

Yeah because there's already support for sections, It's just generating them before the data's populated. I One way could possibly to specify a "sectionKeyPath" which is a property from the object and an option to specify ascending/descending, then just provide a NSComparator block to sort. Also there needs to be a block which presents the property value (as is) and requires a string to be returned for the section name.

spf2 commented 9 years ago

Well, if you know the sections in advance, then it's easier - you can just defer creating the partitioned stream until they are known. As I understand the problem, the tricky part is dynamically adding/removing sections as the data is updated in real-time....

kermankohli commented 8 years ago

Ended up getting the FirebaseUI Objective-C version to work with Swift so it's fine :) Although it could definitely be a nifty feature to have in this library!

spf2 commented 8 years ago

How were you able to address generating sections from object values with that library?

kermankohli commented 8 years ago

Here's the link to the library: https://github.com/firebase/FirebaseUI-iOS/pull/13

Although I find that FirebaseAdapter is more solid than FirebaseUI + better maintenance haha.

kermankohli commented 8 years ago

@spf2 Do you think Firebase Adapter will have support for multiple sections based on a keypath?