If you're using RxSwift, you've probably encountered the following code more than a few times.
class MyCell: UITableViewCell {
var reuseBag = DisposeBag()
override func prepareForReuse() {
super.prepareForReuse()
reuseBag = DisposeBag()
}
}
Instead of adding a new property to every object, use this library to add it for you, to any subclass of UITableViewCell
, UITableViewHeaderFooterView
, UICollectionReusableView
.
thing
.bind(to: otherThing)
.disposed(by: rx.reuseDisposeBag)
RxCell is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'RxCell'
In AppDelegate.swift, just import RxCell framework and enable it.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
RxCell.activate()
return true
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
tr1ckyf0x, vladislav.lisyanskiy@gmail.com Inspired by https://github.com/bmoliveira/Cell-Rx
RxCell is available under the MIT license. See the LICENSE file for more info.