Latest 0.3.1
Homepage https://github.com/devxoul/RxReusable
License MIT
Platforms ios 8.0, requires ARC
Dependencies RxSwift, RxCocoa
Frameworks UIKit, Foundation
Authors

Swift
CocoaPods
Carthage compatible

RxReusable provides some APIs for managing life cycle of reusable cells and views.

APIs

⚠️ In order to use these features properly, you should set delegate by using rx.setDelegate(_:).

UITableView

- tableView.delegate = self
+ tableView.rx.setDelegate(self)

UICollectionView

- collectionView.delegate = self
+ collectionView.rx.setDelegate(self)
  • var disposeBag: DisposeBag

    UITableViewCell and UICollectionView now has their own disposeBag as a property. The dispose bag is automatically disposed on prepareForReuse().

    observable
      .subscribe()
      .addDisposableTo(cell.disposeBag)
  • var isDisplaying: ControlEvent<Bool>

    The reactive wrapper for the cell or view is currently displaying or not. This will emit true when the tableView(_:willDisplay:forRowAt:) or collectionView(_:willDisplay:forItemAt:) is executed and false when the tableView(_:didEndDisplaying:forRowAt:) or collectionView(_:didEndDisplaying:forItemAt:) is executed.

    cell.rx.isDisplaying
      .subscribe(onNext: { isDisplaying in
        print("Cell became (isDisplaying ? "visible" : "invisible")")
      })
  • func whileDisplaying(_:_:)

    This operator makes the observable emit items only when the cell or view is currently displaying or not.

    observable.whileDisplaying(cell, true)  // emit items when the cell is visible
    observable.whileDisplaying(cell, false) // emit items when the cell is not visible

Dependencies

Requirements

  • Swift 3
  • iOS 8+

Installation

  • Using CocoaPods:

    pod 'RxReusable', '~> 0.3'
  • Using Carthage:

    github "devxoul/RxReusable" ~> 0.3

License

RxReusable is under MIT license.

Latest podspec

{
    "name": "RxReusable",
    "version": "0.3.1",
    "summary": "Reusable cells and views for RxSwift",
    "homepage": "https://github.com/devxoul/RxReusable",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Suyeol Jeon": "[email protected]"
    },
    "source": {
        "git": "https://github.com/devxoul/RxReusable.git",
        "tag": "0.3.1"
    },
    "source_files": "RxReusable/Sources/*.swift",
    "frameworks": [
        "UIKit",
        "Foundation"
    ],
    "requires_arc": true,
    "dependencies": {
        "RxSwift": [
            ">= 3.0"
        ],
        "RxCocoa": [
            ">= 3.0"
        ]
    },
    "platforms": {
        "ios": "8.0"
    },
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3.0"
    },
    "pushed_with_swift_version": "3.1"
}

Pin It on Pinterest

Share This