Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make diff code available as a separate component #53

Closed
insidegui opened this issue Oct 12, 2016 · 13 comments
Closed

Make diff code available as a separate component #53

insidegui opened this issue Oct 12, 2016 · 13 comments
Milestone

Comments

@insidegui
Copy link
Contributor

It would be useful to have just the diff algorithm implementation and related protocol used in IGListKit available as a separate component to be used for other purposes (i.e. table views, existing apps that don't want to migrate to IGListKit but want the diffing).

@rnystrom
Copy link
Contributor

rnystrom commented Oct 12, 2016

@insidegui you're in luck, it already is!

If you add IGListKit to your app you can use the diffing by itself. There's an example in the readme for this, but basically:

#import <IGListKit/IGListKit.h>

NSArray *oldStuff = @[...];
NSArray *newStuff = @[...];
IGListIndexSetResult *result = IGListDiff(oldStuff, newStuff, IGListDiffEquality);
// or if you want index paths, where the first two ints are the from/to sections
IGListIndexPathResult *result = IGListDiffPaths(0, 0, oldStuff, newStuff, IGListDiffEquality);

Then you can use the result objects to update the UICollectionView or UITableView. You can use the algorithm and IGListDiffable protocol however/wherever you want.

Now if you want to use the diffing w/out importing the rest of IGListKit (which is arguably not a big framework to add), we might be able to add another Cocoapods spec for that, but I'm not sure its worth the effort of maintaining a separate workspace/tests/etc for that yet.

@insidegui
Copy link
Contributor Author

Awesome! I think it would be useful to have a separate spec, especially since the framework doesn't support macOS yet but the diff code does.

@rnystrom
Copy link
Contributor

Good point re: macOS

@laptobbe
Copy link

@rnystrom Would having it as a subspec in CocoaPods require it to be a separate workspace? If not, maybe that could be solution?

@rnystrom
Copy link
Contributor

rnystrom commented Nov 20, 2016

@laptobbe I'm not sure tbh, I'll have to do a little research to see what options we have. The most important things for this will be:

  • Not interfering w/ existing IGListKit installations
    • Should stay as simple as pod IGListKit or dropping in IGListKit.xcodeproj
  • Compatible w/ internal setup
    • We use buck for Facebook dependency management and already do separate the diffing and main lib, so we can't break that

Ideally I'd love to make another IGListDiffKit.podspec within this repo that only has a select few files as the source, then someone can pod IGListDiffKit and get everything.

Also, importing the entire IGListKit lib isn't that much of a binary size hit, and you can use the diffing algo by itself still. We even have an example of this.

@jessesquires
Copy link
Contributor

Would having it as a subspec in CocoaPods require it to be a separate workspace? If not, maybe that could be solution?

CocoaPods subspec should do the trick, without requiring any major changes. The subspec could specify macOS target compatibility too. (As far as I know.)

I think a subspec gets us 90% of the way there. The problem is that this forces clients to use CocoaPods. (But I like CocoaPods, so ¯\_(ツ)_/¯)

Also, importing the entire IGListKit lib isn't that much of a binary size hit, and you can use the diffing algo by itself still.

Right, but not on macOS or watchOS. (Because of UICollectionView)

@insidegui
Copy link
Contributor Author

I actually made a little repo for myself with the diffing part isolated, the only source changes I had to make involved adding #if TARGET_OS_OSX checks to the umbrella header and IGListDiffCore.mm to import Cocoa on macOS and UIKit on iOS. I am using Carthage so I didn't make a podspec for it.

@jessesquires
Copy link
Contributor

@insidegui -- It is possible to create cross-platform frameworks. Would you want to submit a PR to do this?

Actually -- we should be able to add a macOS target, guard necessary areas with #if TARGET_OS_OSX, and only include the diffing files in the macOS target.

@jessesquires
Copy link
Contributor

An example of a cross-platform ObjC framework:
https://github.com/jessesquires/JSQSystemSoundPlayer

(Slightly different, because this doesn't use UIKit or any iOS specific APIs. But, the general idea is the same.)

@insidegui
Copy link
Contributor Author

Would you want to submit a PR to do this?

I am working on this, will open the PR soon ;)

@insidegui
Copy link
Contributor Author

There you go: #235

@Sherlouk Sherlouk mentioned this issue Dec 24, 2016
6 tasks
@jessesquires jessesquires added this to the 2.1.0 milestone Dec 27, 2016
@Sherlouk
Copy link
Contributor

@jessesquires Flagging for closure

@jessesquires
Copy link
Contributor

Done in #368

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants