-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Model in UITableViewCell class #75
Comments
Hi! You should keep those changes in your data model to be able to update cell state in |
Hello! How do I keep changes in my Eg: I am trying to update like the following example.
|
You can either a) make model mutable(class-based), and save state there. manager.configureCell(CellSubclass.self) { cell, model, indexPath in
// inject closure to call, when state changes(or subscribe to Rx event, if you use Rx.)
cell.onSelectedClosure = {
// capture indexPath here, for example for array of selected cells.
}
} |
a) The ModelTransfer has an immutable model. I have a class-based model.
b) the model in the following is also immutable. How do I update my model
|
If your model is class based, it sure is mutable. So you should be able to set state values in |
I understand your point. I am actually implementing in MVVM, and not saving the models in ViewModel class. Just to add data to tableView and managing its pagination when I add more items. So for me, I couldn’t update the model I supplied to DTTableViewManager when I added the data. I think I need to get the state saved elsewhere like ViewModel and upon |
Whatever you feel is the best for you codebase, it’s hard to advise without knowing context. As for updating cell state, I’d say configureCell or willDisplayCell are the best places so that state is updated correctly before user sees a cell. |
Hi!
In order to save state of the current cell, how to update the model (or any other approach) so to resume the state after scrolling.
E.g: A very simple case, keep UIButton selected state in model class, so after each call of cellForRow, it can be reset to the desired state.
What is equivalent to #this in DTTableViewManager?
The text was updated successfully, but these errors were encountered: