Skip to content

Commit

Permalink
* adds note on using RxCocoa bindTo(_:)
Browse files Browse the repository at this point in the history
  • Loading branch information
icanzilb committed Jan 23, 2017
1 parent c161c16 commit 8b0cf9e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,19 @@ Observable.from(someCollectionOfPersistedObjects)

RxRealm does not depend on UIKit/Cocoa and it doesn't provide built-in way to bind Realm collections to UI components.

There is a separate library __`RxRealmDataSources`__ [link](https://github.com/RxSwiftCommunity/RxRealmDataSources), which mimics the default data sources library for RxSwift
#### a) Non-animated binding

You can use the built-in RxCocoa `bindTo(_:)` method, which will automatically drive your table view from your Realm results:

```swift
Observable.changeset(from: [Realm collection] )
.bindTo(tableView.rx.realmChanges(dataSource))
.addDisposableTo(bag)
```

#### b) Animated binding with RxRealmDataSources

There is a separate library __`RxRealmDataSources`__ [link](https://github.com/RxSwiftCommunity/RxRealmDataSources), which mimics the default data sources library behavior for RxSwift.

`RxRealmDataSources` allows you to bind directly an observable collection of Realm objects to a table or collection view. Here's how the code to bind a collection of laps to a table view looks like:

Expand All @@ -219,7 +231,7 @@ The data source will reflect all changes via animations to the table view:

![RxRealm animated changes](assets/animatedChanges.gif)

If you want to learn more check the __`RxRealmDataSources`__ [README](https://github.com/RxSwiftCommunity/RxRealmDataSources).
If you want to learn more about the features beyond animating changes, check the __`RxRealmDataSources`__ [README](https://github.com/RxSwiftCommunity/RxRealmDataSources).

## Example app

Expand Down

0 comments on commit 8b0cf9e

Please sign in to comment.