Skip to content

LinXunFeng/SwiftyTraceableValue

Repository files navigation

SwiftyTraceableValue

Author CI Status Version License Platform visitors

Article

掘金:ReactorKit + RxDataSources 列表多次刷新的解决方案

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 9.0+
  • Xcode 11+
  • Swift 5+

Installation

SwiftyTraceableValue is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SwiftyTraceableValue'

Usage

1、使用属性包装器 SwiftyTraceableValue 对需要比较属性进行修饰

// Reactor

struct State {
    @SwiftyTraceableValue var sections : [LXFSection] = []
    ...
}

2、使用 mapDistinctUntilTraceableValueChanged 方法,并在对应属性前加上 $

// View

reactor.state.mapDistinctUntilTraceableValueChanged { $0.$sections }
    .bind(to: tableView.rx.items(dataSource: dataSource))
    .disposed(by: disposeBag)

License

SwiftyTraceableValue is available under the MIT license. See the LICENSE file for more info.

Author

Other