Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
ra1028 committed Aug 10, 2018
1 parent aa3c55e commit 45ea6e8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,24 @@ Documentation is generated by [jazzy](https://github.com/realm/jazzy).
- [Playground](https://github.com/ra1028/DifferenceKit/blob/master/DifferenceKit.playground/Contents.swift)

### Example codes
The type of the element that to take the differences must be conform to the `Differentiable` protocol:
The type of the element that to take the differences must be conform to the `Differentiable` protocol.
The `identifier`'s type is determined generic by the associated type:
```swift
struct User: Differentiable {
let id: Int
let name: String

var differenceIdentifier: Int {
var identifier: Int {
return id
}

func isUpdated(from source: User) -> Bool {
return name != source.name
func isContentEqual(to source: User) -> Bool {
return name == source.name
}
}
```

In the case of definition above, `id` uniquely identifies the element and get to know the user updated by comparing `name` of the elements in source and target.
In the case of definition above, `id` uniquely identifies the element and get to know the user updated by comparing equality of `name` of the elements in source and target.

There are default implementations of `Differentiable` for the types that conformed to `Equatable` or `Hashable`
```swift
Expand Down

0 comments on commit 45ea6e8

Please sign in to comment.