项目作者: devxoul

项目描述 :
A ReactorKit extension for managing table view and collection view sections with RxDataSources
高级语言: Swift
项目地址: git://github.com/devxoul/SectionReactor.git
创建时间: 2017-09-09T03:42:56Z
项目社区:https://github.com/devxoul/SectionReactor

开源协议:MIT License

下载


SectionReactor

Swift
CocoaPods
Build Status
Codecov

SectionReactor is a ReactorKit extension for managing table view and collection view sections with RxDataSources.

Getting Started

This is a draft. I have no idea how would I explain this concept 🤦‍♂️ It would be better to see the ArticleFeed example.

ArticleViewSection.swift

  1. enum ArticleViewSection: SectionModelType {
  2. case article(ArticleSectionReactor)
  3. var items: [ArticleViewSection] {
  4. switch self {
  5. case let .article(sectionReactor):
  6. return sectionReactor.currentState.sectionItems
  7. }
  8. }
  9. }

ArticleSectionReactor.swift

  1. import SectionReactor
  2. final class ArticleSectionItem: SectionReactor {
  3. struct State: SectionReactorState {
  4. var sectionItems: [ArticleSectionItem]
  5. }
  6. }

ArticleListViewReactor.swift

  1. final class ArticleListViewReactor: Reactor {
  2. struct State {
  3. var articleSectionReactors: [ArticleSectionReactor]
  4. var sections: [ArticleViewSection] {
  5. return self.articleSectionReactors.map(ArticleViewSection.article)
  6. }
  7. }
  8. func transform(state: Observable<State>) -> Observable<State> {
  9. return state.merge(sections: [
  10. { $0.articleSectionReactors },
  11. ])
  12. }
  13. }

Dependencies

Installation

  1. pod 'SectionReactor'

License

SectionReactor is under MIT license. See the LICENSE for more info.