diff --git a/DiffableDataSources.podspec b/DiffableDataSources.podspec
index 07dbfde..7f62850 100644
--- a/DiffableDataSources.podspec
+++ b/DiffableDataSources.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'DiffableDataSources'
- spec.version = '0.2.0'
+ spec.version = '0.3.0'
spec.author = { 'ra1028' => 'r.fe51028.r@gmail.com' }
spec.homepage = 'https://github.com/ra1028/DiffableDataSources'
spec.documentation_url = 'https://ra1028.github.io/DiffableDataSources'
diff --git a/Gemfile b/Gemfile
index 605a9fe..ea199be 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,4 @@
source "https://rubygems.org"
-gem 'cocoapods', '1.7.5'
-gem 'jazzy', '0.9.4'
+gem 'cocoapods', '1.8.4'
+gem 'jazzy', '0.11.2'
diff --git a/Gemfile.lock b/Gemfile.lock
index 0f6f1b7..321f0be 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,24 +1,27 @@
GEM
remote: https://rubygems.org/
specs:
- CFPropertyList (3.0.1)
+ CFPropertyList (3.0.2)
activesupport (4.2.11.1)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
+ algoliasearch (1.27.1)
+ httpclient (~> 2.8, >= 2.8.3)
+ json (>= 1.5.1)
atomos (0.1.3)
claide (1.0.3)
- cocoapods (1.7.5)
+ cocoapods (1.8.4)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.2, < 2.0)
- cocoapods-core (= 1.7.5)
+ cocoapods-core (= 1.8.4)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.2.2, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-stats (>= 1.0.0, < 2.0)
- cocoapods-trunk (>= 1.3.1, < 2.0)
+ cocoapods-trunk (>= 1.4.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
@@ -27,65 +30,63 @@ GEM
molinillo (~> 0.6.6)
nap (~> 1.0)
ruby-macho (~> 1.4)
- xcodeproj (>= 1.10.0, < 2.0)
- cocoapods-core (1.7.5)
+ xcodeproj (>= 1.11.1, < 2.0)
+ cocoapods-core (1.8.4)
activesupport (>= 4.0.2, < 6)
+ algoliasearch (~> 1.0)
+ concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.4)
- cocoapods-downloader (1.2.2)
+ cocoapods-downloader (1.3.0)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.1.0)
- cocoapods-trunk (1.4.0)
+ cocoapods-trunk (1.4.1)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.1.5)
escape (0.0.4)
- ffi (1.11.1)
+ ffi (1.11.3)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
+ httpclient (2.8.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
- jazzy (0.9.4)
- cocoapods (~> 1.0)
- mustache (~> 0.99)
+ jazzy (0.11.2)
+ cocoapods (~> 1.5)
+ mustache (~> 1.1)
open4
- redcarpet (~> 3.2)
+ redcarpet (~> 3.4)
rouge (>= 2.0.6, < 4.0)
- sass (~> 3.4)
+ sassc (~> 2.1)
sqlite3 (~> 1.3)
xcinvoke (~> 0.3.0)
+ json (2.2.0)
liferaft (0.0.6)
- minitest (5.11.3)
+ minitest (5.13.0)
molinillo (0.6.6)
- mustache (0.99.8)
+ mustache (1.1.1)
nanaimo (0.2.6)
nap (1.1.0)
netrc (0.11.0)
open4 (1.3.4)
- rb-fsevent (0.10.3)
- rb-inotify (0.10.0)
- ffi (~> 1.0)
- redcarpet (3.4.0)
- rouge (3.4.1)
+ redcarpet (3.5.0)
+ rouge (3.13.0)
ruby-macho (1.4.0)
- sass (3.7.4)
- sass-listen (~> 4.0.0)
- sass-listen (4.0.0)
- rb-fsevent (~> 0.9, >= 0.9.4)
- rb-inotify (~> 0.9, >= 0.9.7)
+ sassc (2.2.1)
+ ffi (~> 1.9)
sqlite3 (1.4.1)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
xcinvoke (0.3.0)
liferaft (~> 0.0.6)
- xcodeproj (1.12.0)
+ xcodeproj (1.13.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
@@ -96,8 +97,8 @@ PLATFORMS
ruby
DEPENDENCIES
- cocoapods (= 1.7.5)
- jazzy (= 0.9.4)
+ cocoapods (= 1.8.4)
+ jazzy (= 0.11.2)
BUNDLED WITH
- 2.0.1
+ 2.0.2
diff --git a/README.md b/README.md
index 4693651..5d8872b 100644
--- a/README.md
+++ b/README.md
@@ -144,7 +144,9 @@ let snapshot = DiffableDataSourceSnapshot()
snapshot.appendSections([.main])
snapshot.appendItems(users)
-dataSource.apply(snapshot)
+dataSource.apply(snapshot) {
+ // completion
+}
```
Check the documentation for more detailed API.
diff --git a/Sources/AppKit/CocoaCollectionViewDiffableDataSource.swift b/Sources/AppKit/CocoaCollectionViewDiffableDataSource.swift
index bd6ed6b..2d837d5 100644
--- a/Sources/AppKit/CocoaCollectionViewDiffableDataSource.swift
+++ b/Sources/AppKit/CocoaCollectionViewDiffableDataSource.swift
@@ -33,14 +33,18 @@ open class CocoaCollectionViewDiffableDataSource, animatingDifferences: Bool = true) {
+ /// - completion: An optional completion block which is called when the complete
+ /// performing updates.
+ public func apply(_ snapshot: DiffableDataSourceSnapshot, animatingDifferences: Bool = true, completion: (() -> Void)? = nil) {
core.apply(
snapshot,
view: collectionView,
animatingDifferences: animatingDifferences,
performUpdates: { collectionView, changeset, setSections in
collectionView.reload(using: changeset, setData: setSections)
- })
+ },
+ completion: completion
+ )
}
/// Returns a new snapshot object of current state.
diff --git a/Sources/Internal/DiffableDataSourceCore.swift b/Sources/Internal/DiffableDataSourceCore.swift
index 11a0f1c..b45b757 100644
--- a/Sources/Internal/DiffableDataSourceCore.swift
+++ b/Sources/Internal/DiffableDataSourceCore.swift
@@ -13,7 +13,8 @@ final class DiffableDataSourceCore,
view: View?,
animatingDifferences: Bool,
- performUpdates: @escaping (View, StagedChangeset<[Section]>, @escaping ([Section]) -> Void) -> Void
+ performUpdates: @escaping (View, StagedChangeset<[Section]>, @escaping ([Section]) -> Void) -> Void,
+ completion: (() -> Void)?
) {
dispatcher.dispatch { [weak self] in
guard let self = self else {
@@ -35,15 +36,18 @@ final class DiffableDataSourceCore, animatingDifferences: Bool = true) {
+ /// - completion: An optional completion block which is called when the complete
+ /// performing updates.
+ public func apply(_ snapshot: DiffableDataSourceSnapshot, animatingDifferences: Bool = true, completion: (() -> Void)? = nil) {
core.apply(
snapshot,
view: collectionView,
animatingDifferences: animatingDifferences,
performUpdates: { collectionView, changeset, setSections in
collectionView.reload(using: changeset, setData: setSections)
- })
+ },
+ completion: completion
+ )
}
/// Returns a new snapshot object of current state.
diff --git a/Sources/UIKit/TableViewDiffableDataSource.swift b/Sources/UIKit/TableViewDiffableDataSource.swift
index 67ce2d7..fcc7a1f 100644
--- a/Sources/UIKit/TableViewDiffableDataSource.swift
+++ b/Sources/UIKit/TableViewDiffableDataSource.swift
@@ -36,14 +36,18 @@ open class TableViewDiffableDataSource, animatingDifferences: Bool = true) {
+ /// - completion: An optional completion block which is called when the complete
+ /// performing updates.
+ public func apply(_ snapshot: DiffableDataSourceSnapshot, animatingDifferences: Bool = true, completion: (() -> Void)? = nil) {
core.apply(
snapshot,
view: tableView,
animatingDifferences: animatingDifferences,
performUpdates: { tableView, changeset, setSections in
tableView.reload(using: changeset, with: self.defaultRowAnimation, setData: setSections)
- })
+ },
+ completion: completion
+ )
}
/// Returns a new snapshot object of current state.
diff --git a/Tests/CocoaCollectionViewDiffableDataSourceTests.swift b/Tests/CocoaCollectionViewDiffableDataSourceTests.swift
index ca54824..c500e01 100644
--- a/Tests/CocoaCollectionViewDiffableDataSourceTests.swift
+++ b/Tests/CocoaCollectionViewDiffableDataSourceTests.swift
@@ -22,21 +22,29 @@ final class CocoaCollectionViewDiffableDataSourceTests: XCTestCase {
var snapshot = DiffableDataSourceSnapshot()
- dataSource.apply(snapshot)
+ let e1 = expectation(description: "testApply() e1")
+ dataSource.apply(snapshot, completion: e1.fulfill)
+ wait(for: [e1], timeout: 1)
XCTAssertEqual(collectionView.isPerformBatchUpdatesCalledCount, 0)
snapshot.appendSections([0])
snapshot.appendItems([0])
- dataSource.apply(snapshot)
+ let e2 = expectation(description: "testApply() e2")
+ dataSource.apply(snapshot, completion: e2.fulfill)
+ wait(for: [e2], timeout: 1)
XCTAssertEqual(collectionView.isPerformBatchUpdatesCalledCount, 1)
- dataSource.apply(snapshot)
+ let e3 = expectation(description: "testApply() e3")
+ dataSource.apply(snapshot, completion: e3.fulfill)
+ wait(for: [e3], timeout: 1)
XCTAssertEqual(collectionView.isPerformBatchUpdatesCalledCount, 1)
snapshot.appendItems([1])
- dataSource.apply(snapshot)
+ let e4 = expectation(description: "testApply() e4")
+ dataSource.apply(snapshot, completion: e4.fulfill)
+ wait(for: [e4], timeout: 1)
XCTAssertEqual(collectionView.isPerformBatchUpdatesCalledCount, 2)
}
diff --git a/Tests/CollectionViewDiffableDataSourceTests.swift b/Tests/CollectionViewDiffableDataSourceTests.swift
index e419a54..872683a 100644
--- a/Tests/CollectionViewDiffableDataSourceTests.swift
+++ b/Tests/CollectionViewDiffableDataSourceTests.swift
@@ -22,21 +22,29 @@ final class CollectionViewDiffableDataSourceTests: XCTestCase {
var snapshot = DiffableDataSourceSnapshot()
- dataSource.apply(snapshot)
+ let e1 = expectation(description: "testApply() e1")
+ dataSource.apply(snapshot, completion: e1.fulfill)
+ wait(for: [e1], timeout: 1)
XCTAssertEqual(collectionView.isPerformBatchUpdatesCalledCount, 0)
snapshot.appendSections([0])
snapshot.appendItems([0])
- dataSource.apply(snapshot)
+ let e2 = expectation(description: "testApply() e2")
+ dataSource.apply(snapshot, completion: e2.fulfill)
+ wait(for: [e2], timeout: 1)
XCTAssertEqual(collectionView.isPerformBatchUpdatesCalledCount, 1)
- dataSource.apply(snapshot)
+ let e3 = expectation(description: "testApply() e3")
+ dataSource.apply(snapshot, completion: e3.fulfill)
+ wait(for: [e3], timeout: 1)
XCTAssertEqual(collectionView.isPerformBatchUpdatesCalledCount, 1)
snapshot.appendItems([1])
- dataSource.apply(snapshot)
+ let e4 = expectation(description: "testApply() e4")
+ dataSource.apply(snapshot, completion: e4.fulfill)
+ wait(for: [e4], timeout: 1)
XCTAssertEqual(collectionView.isPerformBatchUpdatesCalledCount, 2)
}
diff --git a/Tests/TableViewDiffableDataSourceTests.swift b/Tests/TableViewDiffableDataSourceTests.swift
index c29cd3f..ce3e1cb 100644
--- a/Tests/TableViewDiffableDataSourceTests.swift
+++ b/Tests/TableViewDiffableDataSourceTests.swift
@@ -22,21 +22,29 @@ final class TableViewDiffableDataSourceTests: XCTestCase {
var snapshot = DiffableDataSourceSnapshot()
- dataSource.apply(snapshot)
+ let e1 = expectation(description: "testApply() e1")
+ dataSource.apply(snapshot, completion: e1.fulfill)
+ wait(for: [e1], timeout: 1)
XCTAssertEqual(tableView.isPerformBatchUpdatesCalledCount, 0)
snapshot.appendSections([0])
snapshot.appendItems([0])
- dataSource.apply(snapshot)
+ let e2 = expectation(description: "testApply() e2")
+ dataSource.apply(snapshot, completion: e2.fulfill)
+ wait(for: [e2], timeout: 1)
XCTAssertEqual(tableView.isPerformBatchUpdatesCalledCount, 1)
- dataSource.apply(snapshot)
+ let e3 = expectation(description: "testApply() e3")
+ dataSource.apply(snapshot, completion: e3.fulfill)
+ wait(for: [e3], timeout: 1)
XCTAssertEqual(tableView.isPerformBatchUpdatesCalledCount, 1)
snapshot.appendItems([1])
- dataSource.apply(snapshot)
+ let e4 = expectation(description: "testApply() e4")
+ dataSource.apply(snapshot, completion: e4.fulfill)
+ wait(for: [e4], timeout: 1)
XCTAssertEqual(tableView.isPerformBatchUpdatesCalledCount, 2)
}
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 980d73a..b4c7046 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -10,6 +10,8 @@ jobs:
matrix:
xcode10_2:
DEVELOPER_DIR: /Applications/Xcode_10.2.app
+ xcode11_2_1:
+ DEVELOPER_DIR: /Applications/Xcode_11.2.1.app
steps:
- checkout: self
submodules: true
@@ -24,7 +26,7 @@ jobs:
condition: succeededOrFailed()
- script: |
set -o pipefail &&
- xcodebuild build-for-testing test-without-building -workspace DiffableDataSources.xcworkspace -scheme DiffableDataSources -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone Xs' ENABLE_TESTABILITY=YES |
+ xcodebuild build-for-testing test-without-building -workspace DiffableDataSources.xcworkspace -scheme DiffableDataSources -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8' ENABLE_TESTABILITY=YES |
xcpretty -c -r junit -o build/reports/xcodebuild-iOS.xml
displayName: xcodebuild test iOS
condition: succeededOrFailed()
diff --git a/docs/Classes/CollectionViewDiffableDataSource.html b/docs/Classes/CollectionViewDiffableDataSource.html
index ed97757..ba23473 100644
--- a/docs/Classes/CollectionViewDiffableDataSource.html
+++ b/docs/Classes/CollectionViewDiffableDataSource.html
@@ -235,9 +235,9 @@ changes with automatic diffing.
@@ -252,7 +252,7 @@ changes with automatic diffing.
Declaration
Swift
-
public func apply(_ snapshot: DiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>, animatingDifferences: Bool = true)
+
public func apply(_ snapshot: DiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>, animatingDifferences: Bool = true, completion: (() -> Void)? = nil)
@@ -285,6 +285,19 @@ changes with automatic diffing.
+
+
+
+ completion
+
+ |
+
+
+ An optional completion block which is called when the complete
+ performing updates.
+
+ |
+
@@ -678,8 +691,8 @@ changes with automatic diffing.