Open zdnk opened 6 years ago
Have a look at the example macOS where we are using the ListAdapter
to drive a NSCollectionView
, see: https://github.com/Instagram/IGListKit/blob/d6e26d54e85a5c745a38a2693e34ae9fbbc0d639/Examples/Examples-macOS/IGListKitExamples/ViewControllers/UsersViewController.swift#L57-L87
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:
A1
A1
in descending orderA
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.
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.