/// Pure function mapping new state to a new `TableViewModel`. This is invoked each time the state updates /// in order for ReactiveLists to update the UI. static func viewModel(forState groups: [ToolGroup]) -> TableViewModel { // Create a section for every tool group let sections: [TableSectionViewModel] = groups.map { group in // Create a single cell for every tool let cellViewModels = group.tools.map { ToolTableCellModel(tool: $0) } return TableSectionViewModel( headerTitle: group.name, headerHeight: 44, cellViewModels: cellViewModels, diffingKey: group.name ) } return TableViewModel(sectionModels: sections) }