GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - RACCommunity/FlexibleDiff: A Swift collection diffing μframework.

BranchesTags
Open more actions menu

Latest commit

 

History

23 Commits
23 Commits

Folders and files

NameName
Last commit message
Last commit date
Carthage/Checkouts
Carthage/Checkouts
 
 
FlexibleDiff.xcodeproj
FlexibleDiff.xcodeproj
 
 
FlexibleDiff.xcworkspace
FlexibleDiff.xcworkspace
 
 
FlexibleDiff
FlexibleDiff
 
 
FlexibleDiffTests
FlexibleDiffTests
 
 
WordList
WordList
 
 
script
script
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
.swift-version
.swift-version
 
 
.travis.yml
.travis.yml
 
 
Cartfile
Cartfile
 
 
Cartfile.private
Cartfile.private
 
 
Cartfile.resolved
Cartfile.resolved
 
 
FlexibleDiff.podspec
FlexibleDiff.podspec
 
 
LICENSE.md
LICENSE.md
 
 
Package.resolved
Package.resolved
 
 
Package.swift
Package.swift
 
 
[email protected]
[email protected]
 
 
README.md
README.md
 
 

Repository files navigation

Introduction

FlexibleDiff is a simple collection diffing μframework for Swift, allowing separated defintions of identity and equality for the purpose of diffing.

For general business concerns, full inequality of two instances does not necessarily mean inequality in term of identity — it just means the data being held has changed if the identity of both instances are the same. However, as most of the diffing μframeworks rely on only — and therefore are constrained by — the Equatable requirement, they are not capable of expressing the identical-but-unequal scenarios which are common especially in interactive applications.

FlexibleDiff addresses the issue by supporting changeset computation with custom definitions for equality and identity.

For example, given these definitions:

let previous: [Book]
let current: [Book]

struct Book: Equatable {
    let isbn: String
    var name: String
    var publishedOn: [Date]
}

We may supply a custom identity definition, and get to know about in-place mutated books, or mutated books at a different position, on the basis of books being identified only by their ISBN.

let changeset = Changeset(previous: previous,
                          current: current,
                          identifier: { book in book.isbn },
                          areEqual: Book.==)

The improved expressivity of the diff, as compared to conventional Equatable -based μframeworks, allows more fitting collection view animations to be issued.

On top of the flexible API, FlexibleDiff provides also several conveniences for common use cases:

Collection.Element Identified By Compared By
AnyObject Object identity Object identity
AnyObject & Equatable Object identity Object identity or value equality.
AnyObject & Hashable Object identity, or value equality. Object identity, or value equality.
Hashable Value equality Value equality

Getting Started

FlexibleDiff is offered as a standalone Xcode project, and supports both Carthage and CocoaPods.

# Carthage
github "RACCommunity/FlexibleDiff"

# CocoaPods
pod "FlexibleDiff"

The Example App

The Xcode workspace includes an example app using FlexibleDiff. Be sure to run git submodule update --init to fetch the dependencies before building the app target in Xcode.

Note on the algorithm

The implementation is evolved from the popular O(n) diff algorithm by Paul Heckel, in his 1978 paper "A technique for isolating differences between files". The algorithm serves as the basis of many frameworks across multiple platforms, including but not limited to IGListKit.

License

Licensed under the MIT License.

About

A Swift collection diffing μframework.

Resources

Readme
MIT license
Activity
Custom properties

Stars

106 stars

Watchers

4 watching

Forks

8 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.