Skip to content

Commit 153d788

Browse files
AlexShubinkzaher
authored andcommitted
equatable AnimatableSectionModel
1 parent 3d27d25 commit 153d788

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.
66
#### Enhancements
77
* Reduce computational complexity. #242
88
* Adapted for RxSwift 4.2
9-
* Makes SectionModel equatable when its model and items conforms to equatable.
9+
* Makes SectionModel and AnimatableSectionModel equatable when their model and items conforms to equatable.
1010

1111
## [3.1.0](https://github.com/RxSwiftCommunity/RxDataSources/releases/tag/3.1.0)
1212

Sources/Differentiator/AnimatableSectionModel.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,14 @@ extension AnimatableSectionModel
4747
}
4848

4949
}
50+
51+
#if swift(>=4.1)
52+
extension AnimatableSectionModel
53+
: Equatable where Section: Equatable {
54+
55+
public static func == (lhs: AnimatableSectionModel, rhs: AnimatableSectionModel) -> Bool {
56+
return lhs.model == rhs.model
57+
&& lhs.items == rhs.items
58+
}
59+
}
60+
#endif

Sources/Differentiator/SectionModel.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,20 @@ extension SectionModel
3636
}
3737
}
3838

39+
extension SectionModel {
40+
public init(original: SectionModel<Section, Item>, items: [Item]) {
41+
self.model = original.model
42+
self.items = items
43+
}
44+
}
45+
3946
#if swift(>=4.1)
4047
extension SectionModel
4148
: Equatable where Section: Equatable, ItemType: Equatable {
49+
4250
public static func == (lhs: SectionModel, rhs: SectionModel) -> Bool {
4351
return lhs.model == rhs.model
4452
&& lhs.items == rhs.items
4553
}
4654
}
4755
#endif
48-
49-
extension SectionModel {
50-
public init(original: SectionModel<Section, Item>, items: [Item]) {
51-
self.model = original.model
52-
self.items = items
53-
}
54-
}

0 commit comments

Comments
 (0)