Iglistkit: [IGListDiff] How to get actual steps

Created on 7 Nov 2017  路  10Comments  路  Source: Instagram/IGListKit

Hello,
I would like to use diffing algorithm from IGListKit for my project and I am missing an information how to use it to get actual steps to get from original array to new one. There are moves, updates, deletes and inserts, but how do I apply them, what order. I would really appreciate this information as it is vital for what I need to do with it.

question

Most helpful comment

Yep, it should be virtual view hierarchy. The current one vs the new one. Working on a little framework, something similar to React. Also using Yoga for layout.

All 10 comments

What should this tell me? I dont understand.
My use case is I have two arrays. I will call ListDiff and then I need to use it somehow to get from array A to array B by applying insertions, deletions and moves on it.

Can you tell me what you exactly want to do? I understand you have array A and B and you use ListDiff to determine the changes, all the inserts, movements, deleted etc. This data is used the above example to animate the differences in NSCollectionView through performBatchUpdates

I just need to know what actions/steps to perform to get from that array A to B ... Meaning how to apply those insertions, deletions etc. In what order lets say.

Delete, Insert, Move,

See also the file below as used in flushCollectionView in IGListAdapterUpdater https://github.com/Instagram/IGListKit/blob/master/Source/Internal/UICollectionView%2BIGListBatchUpdateData.m

@zdenektopic I'm a little confused why if you already have array B why you need to replay those steps. Can you described a little more what you're trying to achieve?

Replaying the mutations will be tricky as deletes and inserts will mutate the array as you're editing them. But something like:

  • Create a mutable copy A1
  • Do all reloads
  • Delete from array A1 in descending order
  • Perform inserts in ascending order
  • Move from array A into A1

I am trying to modify view hierarchy. I have view with subviews, some of those subviews have also subviews. And I want to do diff of two hierarchies and apply the diff on the old one so it is turned into new one. Also apply animations on those being removed/inserted.

You should be able to use the above steps to perform the operations. You'll also need some sort of in-order "pool" of new stuff to pull from for inserts.

Are you diffing like a virtual view hierarchy or something? Where do the new views come from?

Yep, it should be virtual view hierarchy. The current one vs the new one. Working on a little framework, something similar to React. Also using Yoga for layout.

Super cool. Let me know where you end up!

Sent with GitHawk

Was this page helpful?
0 / 5 - 0 ratings