You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To run the example project, clone the repo, and run pod install from the Example directory first.
Usage
This library is a light data source implementation for RxRealm. It allows you to easily bind an Observable sequence of Realm objects to a table or a collection view. The library is both iOS and macOS compatible.
Binding to a table view
Check out the included demo app to see this in action.
// create data source
letdataSource=RxTableViewRealmDataSource<Lap>(cellIdentifier:"Cell", cellType:PersonCell.self){cell, ip, lap in
cell.customLabel.text ="\(ip.row). \(lap.text)"}
// RxRealm to get Observable<Results>
letrealm=try!Realm(configuration:DataRandomizer.realmConfig)letlaps=Observable.changeset(from: realm.objects(Timer.self).first!.laps).share()
// bind to table view
laps
.bindTo(tableView.rx.realmChanges(dataSource)).disposed(by: bag)
Binding to a collection view
Check out the included demo app to see this in action.
// create data source
letdataSource=RxCollectionViewRealmDataSource<Lap>(cellIdentifier:"Cell", cellType:LapCollectionCell.self){cell, ip, lap in
cell.customLabel.text ="\(ip.row). \(lap.text)"}
// RxRealm to get Observable<Results>
letrealm=try!Realm(configuration:DataRandomizer.realmConfig)letlaps=Observable.changeset(from: realm.objects(Timer.self).first!.laps).share()
// bind to collection view
laps
.bindTo(collectionView.rx.realmChanges(dataSource)).disposed(by: bag)
Reacting to cell taps
The library adds an extension to table views and collection views, allowing you to easily subscribe to the cell selected delegate event. Here's a snippet from the example demo app: