Adopting walkarounds for UICollectionView
Usipov opened this issue · comments
The original implementation of the diffing algorythm has some walkarounds to respect UICollectionView
's internal behaviour and prevent UICollectionView
from throwing exceptions in performBatchUpdates
function:
https://github.com/Instagram/IGListKit/blob/master/Source/Common/IGListIndexPathResult.m#L41
https://github.com/Instagram/IGListKit/blob/master/Source/Common/IGListIndexSetResult.m#L43
Without those walkarounds I receive lots of
attempt to perform a delete and a move from the same index path (<NSIndexPath: 0xc00000000ce00016> {length = 2, path = 0 - 103})
in a stress test with a collection of 1000 elements being under repeated random inserts, deletes, moves and updates repeated
So, I wonder, were there any reasons for loosing that functionality in this port?
Hey! It’s very likely that the port was based on an older version of the algorithm.
I’ll have to re-review the 2 codebase to see if I miss out anything.
Originally, this is a 1-1 reference implementation of the IGListKit and I intend to keep it that way though. Do you have any idea what part of the code is missing?
If you can share with me a stress testing code I can try to spend some time on this over the weekend!
Thanks for such a fast reply!
I linked to the missing parts in the original message. These are the functions called resultForBatchUpdates
I will try to share the test or the missing code for a batch updates soon
I also see, that original diffing algorythm supports index paths diff in complement with index diff, while the ported algorythm supports only index diff
Again, see the links in the original message
Just use
let diff = List.diffing(
oldArray: from,
newArray: to
).forBatchUpdates()
instead of
let diff = List.diffing(
oldArray: from,
newArray: to
)
Note .forBatchUpdates()
in the end.
Sorry, I do not have time for pull requests at the moment.