Skip to content

Drop-in iOS filterable replacements for FirebaseUI's FUIBatchedArray and FUIFirestoreCollectionViewDataSource

Notifications You must be signed in to change notification settings

red42/FilteredFirestoreDataSource

Repository files navigation

Filterable Firestore Datasource replacement for FirebaseUI-iOS

Drop-in iOS filterable replacements for FirebaseUI's FUIBatchedArray and FUIFirestoreCollectionViewDataSource in Swift.

Unlike FirebaseUI on Android, the iOS FUIFirestoreCollectionViewDataSource is not easily extendable, so filtering data after the snapshot is received is a challenge.

These drop-in replacements for FUIBatchedArray and FUIFirestoreCollectionViewDataSource provide a setFilter(_:) method to allow a DocumentSnapshot filter to be set on the datasource, which is applied on FilteredBatchedArray's snapshot listener.

The filter is a closure applicable to a [DocumentSnapshot] array. In other words, a (DocumentSnapshot)->Bool closure.

Usage

var dataSource:FilteredFirestoreCollectionViewDataSource?
let goodIdArray = ["goodId_1", "goodId_2"]

dataSource = collectionView.bind(toFirestoreQuery: query) { (collectionView, indexPath, documentSnapshot) -> UICollectionViewCell in
  // populateCell body
}

dataSource.setFilter({ goodIdArray.contains($0.documentID) })

A FUIFirestoreTableViewDataSource version should be trivial to implement.

About

Drop-in iOS filterable replacements for FirebaseUI's FUIBatchedArray and FUIFirestoreCollectionViewDataSource

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages