Skip to content

Commit 093b137

Browse files
committed
Added completions to SPDiffable.
1 parent 8a30df3 commit 093b137

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

SPDiffable.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SPDiffable'
4-
s.version = '1.6.2'
4+
s.version = '1.6.4'
55
s.summary = 'Extenshion of Diffable API which allow not duplicate code and use less models.'
66
s.homepage = 'https://github.com/ivanvorobei/SPDiffable'
77
s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version }

Sources/SPDiffable/DataSource/SPDiffableCollectionDataSource.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
7979
- parameter sections: Array of `SPDiffableSection`, it content of table.
8080
- parameter animating: Shoud apply changes with animation or not.
8181
*/
82-
public func apply(_ sections: [SPDiffableSection], animated: Bool) {
82+
public func apply(_ sections: [SPDiffableSection], animated: Bool, completion: (() -> Void)? = nil) {
8383
if #available(iOS 14, *) {
8484

8585
var snapshot = self.snapshot()
@@ -126,7 +126,7 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
126126

127127
// Apply Changes
128128

129-
apply(snapshot, animated: true)
129+
apply(snapshot, animated: true, completion: completion)
130130

131131
// Update items in Sections
132132

@@ -152,7 +152,7 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
152152
for section in sections {
153153
snapshot.appendItems(section.items, toSection: section)
154154
}
155-
apply(snapshot, animatingDifferences: animated)
155+
apply(snapshot, animatingDifferences: animated, completion: completion)
156156
}
157157
}
158158

@@ -162,8 +162,8 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
162162
- parameter snapshot: New snapshot.
163163
- parameter animating: Shoud apply changes with animation or not.
164164
*/
165-
public func apply(_ snapshot: SPDiffableSnapshot, animated: Bool) {
166-
apply(snapshot, animatingDifferences: animated, completion: nil)
165+
public func apply(_ snapshot: SPDiffableSnapshot, animated: Bool, completion: (() -> Void)? = nil) {
166+
apply(snapshot, animatingDifferences: animated, completion: completion)
167167
}
168168

169169
// MARK: - Reload Content

Sources/SPDiffable/DataSource/SPDiffableTableDataSource.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,22 @@ open class SPDiffableTableDataSource: UITableViewDiffableDataSource<SPDiffableSe
6464

6565
- parameter sections: Array of `SPDiffableSection`, it content of table.
6666
- parameter animating: Shoud apply changes with animation or not.
67+
- parameter completion: A closure to execute when the animations are complete.
6768
*/
68-
public func apply(_ sections: [SPDiffableSection], animated: Bool) {
69+
public func apply(_ sections: [SPDiffableSection], animated: Bool, completion: (() -> Void)? = nil) {
6970
let snapshot = convertToSnapshot(sections)
70-
apply(snapshot, animatingDifferences: animated)
71+
apply(snapshot, animatingDifferences: animated, completion: completion)
7172
}
7273

7374
/**
7475
SPDiffable: Applying new snapshot insted of current.
7576

7677
- parameter snapshot: New snapshot.
7778
- parameter animating: Shoud apply changes with animation or not.
79+
- parameter completion: A closure to execute when the animations are complete.
7880
*/
79-
public func apply(_ snapshot: SPDiffableSnapshot, animated: Bool) {
80-
apply(snapshot, animatingDifferences: animated, completion: nil)
81+
public func apply(_ snapshot: SPDiffableSnapshot, animated: Bool, completion: (() -> Void)? = nil) {
82+
apply(snapshot, animatingDifferences: animated, completion: completion)
8183
}
8284

8385
// MARK: - Reload Content

0 commit comments

Comments
 (0)