Skip to content

Commit

Permalink
Fixes problem with editing UITableView example. ReactiveX#768
Browse files Browse the repository at this point in the history
  • Loading branch information
kzaher committed Jul 4, 2016
1 parent ca831c7 commit 95ee9d0
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ class TableViewWithEditingCommandsViewController: ViewController, UITableViewDel
.observeOn(MainScheduler.instance)

let deleteUserCommand = tableView.rx_itemDeleted.map(TableViewEditingCommand.DeleteUser)
let moveUserCommand = tableView.rx_itemMoved.map(TableViewEditingCommand.MoveUser)
let moveUserCommand = tableView
.rx_itemMoved
// This is needed because rx_itemMoved is being performed before delegate method is
// delegated to RxDataSource.
// This observeOn makes sure data is rebound after automatic move is performed in data source.
// This will be improved in RxSwift 3.0 when order will be inversed.
.observeOn(MainScheduler.asyncInstance)
.map(TableViewEditingCommand.MoveUser)

let initialState = TableViewEditingCommandsViewModel(favoriteUsers: [], users: [])

Expand Down Expand Up @@ -171,6 +178,10 @@ class TableViewWithEditingCommandsViewController: ViewController, UITableViewDel
return true
}

dataSource.canMoveRowAtIndexPath = { _ in
return true
}

return dataSource
}

Expand Down

0 comments on commit 95ee9d0

Please sign in to comment.