IGListKit icon indicating copy to clipboard operation
IGListKit copied to clipboard

Question: IGListBindingController vs performUpdate on ViewController

Open seanliu1 opened this issue 6 years ago • 0 comments

I am reading the IGListBindingController for https://github.com/Instagram/IGListKit/blob/master/Guides/Modeling%20and%20Binding.md

In the post example, since localelikes is a variable on PostSectionController. If section controller is recreated, will we lose all locale likes?

What I have done before is to let viewmodel has action delegate back to view controller, then change the data source and call performupdate. I admit this is a pretty heavy process. In the post example, what I will do is

 func onHeart() {
  viewModel?.tapHeart(cell: self)
}

Then ViewController will increment likes,replace a new viewmodel with new likes, and call performUpdate. If I want to do any locale uichange such as expand or collapse cell, I will often do following in the section controller

collectionContext?.performBatch(animated: true, updates: { batchContext in
            self.expanded.toggle()
            batchContext.reload(self)
        }, completion: nil)

What is the recommended approach and how do handle section controller reuse issue?

seanliu1 avatar Aug 25 '19 18:08 seanliu1