Guest User

Untitled

a guest
Feb 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. /// Pure function mapping new state to a new `TableViewModel`. This is invoked each time the state updates
  2. /// in order for ReactiveLists to update the UI.
  3. static func viewModel(forState groups: [ToolGroup]) -> TableViewModel {
  4. // Create a section for every tool group
  5. let sections: [TableSectionViewModel] = groups.map { group in
  6. // Create a single cell for every tool
  7. let cellViewModels = group.tools.map { ToolTableCellModel(tool: $0) }
  8. return TableSectionViewModel(
  9. headerTitle: group.name,
  10. headerHeight: 44,
  11. cellViewModels: cellViewModels,
  12. diffingKey: group.name
  13. )
  14. }
  15. return TableViewModel(sectionModels: sections)
  16. }
Add Comment
Please, Sign In to add comment