Iglistkit: [RFC] Provide UIKit bindings for diffs *outside* of the SectionController + ListAdapter flow

Created on 27 Jul 2017  路  3Comments  路  Source: Instagram/IGListKit

Provide UIKit bindings for diffs outside of the SectionController + ListAdapter flow

One barrier to using IGLK is adopting the SectionController + ListAdapter architecture, which is difficult for legacy projects, or projects that have adopted other "list" abstractions but now want to implement diffing for those lists.

Currently, we provide a Diffing subspec, but this requires clients to write bindings to UICollectionView and UITableView themselves. IGLK should provide this instead.

Proposal

Provide extension methods on UITableView and UICollectionView that will perform updates on the view given the results from the IGListDiff C functions. Essentially, we want to expose the functionality of IGListAdapterUpdater in way that allows clients to perform updates without using SectionControllers and ListAdapters.

Pseudo example

let old = //...

let new = //....

let diffResults = ListDiff(oldArray:old newArray:new option:IGListDiffEquality)

collectionView.performBatchUpdates(diffResults: diffResults, completion: {
    // completion block
})

// table view follows similarly
enhancement proposal

Most helpful comment

@rnystrom -- 馃挴 yeah, let's do the simpler, "least intrusive" solution first

All 3 comments

So on board with this. Will be trivial.

@jessesquires what do you think about creating a "light" adapter that does:

  • Give it an array of diffable models, diffs+applies update
  • One section, array powers numberOfItems
  • IGListBindable cells, automatically binds view models

This would solve our UITableView issue without refactoring the world (I still think full table support will open a world of hurt).

Maybe we solve "apply diff update" category first then this?

Sounds reasonable to my ears, @rnystrom :)

@rnystrom -- 馃挴 yeah, let's do the simpler, "least intrusive" solution first

Was this page helpful?
0 / 5 - 0 ratings