Skip to content

Commit

Permalink
Update podspec and README.
Browse files Browse the repository at this point in the history
  • Loading branch information
lm2343635 committed Aug 5, 2019
1 parent 47fd9ab commit 2f89c0c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PODS:
- RxCocoa (5.0.0):
- RxRelay (~> 5)
- RxSwift (~> 5)
- RxController (0.7.3):
- RxController (0.7.4):
- RxCocoa (~> 5)
- RxFlow (~> 2)
- RxSwift (~> 5)
Expand Down Expand Up @@ -64,7 +64,7 @@ SPEC CHECKSUMS:
Reusable: 82be188f29d96dc5eff0db7b2393bcc08d2cdd5b
RxBinding: 58be2cf1311165489a66eacb4a3e33932d598a53
RxCocoa: fcf32050ac00d801f34a7f71d5e8e7f23026dcd8
RxController: b488ac97a465e30d127e6451e8e7d93429b72f44
RxController: bd7fb19277fed720e394cd30708c1f5bc9a24db9
RxDataSources: efee07fa4de48477eca0a4611e6d11e2da9c1114
RxDataSourcesSingleSection: 42ee6900e6c069ce2d0bb9a1cd81308dce772d28
RxFlow: ee6f1fdbacfa4ca8926122e466dfba32e3edf73f
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,17 @@ var name: Observable<String?> {
```

Pay attention to that **subscribing the `RxControllerEvent` in the `init` method of the view model is not effective**.
It necessary to subscribe the `RxControllerEvent` in the `prepareForParentEvents` methods like:
It necessary to subscribe or bind the `RxControllerEvent` in the `prepareForParentEvents` methods.

```Swift
override func prepareForParentEvents() {
parentEvents.unwrappedValue(of: Event.sample, type: EventData.self)
.bind(to: data).disposed(by: disposeBag)
// Subscribe an event.
parentEvents.unwrappedValue(of: Event.sample, type: EventData.self).subscribe(onNext: {
// ...
}.disposed(by: disposeBag))

// Bind an event to a relay directly.
parentEvents.bind(of: Event.sample, to: data).disposed(by: disposeBag)
}
```

Expand Down
2 changes: 1 addition & 1 deletion RxController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'RxController'
s.version = '0.7.3'
s.version = '0.7.4'
s.summary = 'A library for developing with MVVM-C based on RxFlow and RxSwift.'

# This description is used to generate tags and improve search results.
Expand Down
42 changes: 41 additions & 1 deletion document/chapter6-cell.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ extension PersonTableViewCell: Configurable {
## 6.3 Table view cell height

Calculating cell height is a troublesome problem for the table view cell.
If the cell height is dynamical, using autolayout using SnapKit in the cell and automatic row height in the table view is recommended.

```swift
private lazy var tableView: UITableView = {
let tableView = UITableView()
tableView.rowHeight = UITableView.automaticDimension
tableView.register(cellType: DemoTableViewCell.self)
return tableView
}()
```

In the cell class, the autolayout rule is different with which in the view controller or the customized view.

## 6.4 Tap action

Expand Down Expand Up @@ -114,7 +126,7 @@ func pick(at index: Int) {
Sometimes, a single cell may contains multiple tap action for multiple customized buttons.
In the view controller, the reactive extension is recommended in the definition closure of the customized buttons.
However, for the reusable cells, managing the `disposeBag` and avoiding the multiple tap action binding are troublesome.
As we said in the top of this chapter, we use the pure MVC design pattern for reusable cells.
As we said in the top of this chapter, **the pure MVC design pattern is recommended for handling events of reusable cells.**
Here, we define the customized button and add tap action with `addTarget` method directly.

```swift
Expand All @@ -126,3 +138,31 @@ private lazy var favoriteButton: UIButton = {
return button
}()
```

When the button is tapped, the objc method will be invoked.

```swift
@objc
private func favoriteTapped() {
didFavoriteTapped?()
}
```
In this private method, an optional closure is invoked.
This clousre is defined as an internal optional property.

```swift
var didFavoriteTapped: (() -> Void)?
```

The tapped closure should be setted in the dataSource of the tableView.

```swift
private lazy var dataSource = FavoriteTableViewCell.tableViewSingleSectionDataSource(configureCell: { [unowned self] cell, indexPath, _ in
cell.didFavoriteTapped = {
self.viewModel.pick(at: indexPath.row)
}
})
```

At last, a method in the view model will be invoked.
This method is responsible for handling the specific business logic.

0 comments on commit 2f89c0c

Please sign in to comment.