mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-25 01:58:45 +02:00
WIP
This commit is contained in:
@@ -116,10 +116,10 @@ extension DiffableDataSource {
|
|||||||
target.reload(
|
target.reload(
|
||||||
using: changeset,
|
using: changeset,
|
||||||
animated: animatingDifferences,
|
animated: animatingDifferences,
|
||||||
setData: setSections
|
setData: setSections,
|
||||||
|
completion: completion
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
completion: completion
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,10 +148,10 @@ extension DiffableDataSource {
|
|||||||
target.reload(
|
target.reload(
|
||||||
using: changeset,
|
using: changeset,
|
||||||
animated: animatingDifferences,
|
animated: animatingDifferences,
|
||||||
setData: setSections
|
setData: setSections,
|
||||||
|
completion: completion
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
completion: completion
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,9 +207,9 @@ extension DiffableDataSource {
|
|||||||
self.base?.moveItem(at: indexPath, to: newIndexPath)
|
self.base?.moveItem(at: indexPath, to: newIndexPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func performBatchUpdates(updates: () -> Void, animated: Bool) {
|
public func performBatchUpdates(updates: () -> Void, animated: Bool, completion: @escaping () -> Void) {
|
||||||
|
|
||||||
self.base?.animator().performBatchUpdates(updates, completionHandler: nil)
|
self.base?.animator().performBatchUpdates(updates, completionHandler: { _ in completion() })
|
||||||
}
|
}
|
||||||
|
|
||||||
public func reloadData() {
|
public func reloadData() {
|
||||||
|
|||||||
@@ -207,9 +207,9 @@ extension DiffableDataSource {
|
|||||||
self.base?.moveItem(at: indexPath, to: newIndexPath)
|
self.base?.moveItem(at: indexPath, to: newIndexPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func performBatchUpdates(updates: () -> Void, animated: Bool) {
|
public func performBatchUpdates(updates: () -> Void, animated: Bool, completion: @escaping () -> Void) {
|
||||||
|
|
||||||
self.base?.performBatchUpdates(updates, completion: nil)
|
self.base?.performBatchUpdates(updates, completion: { _ in completion() })
|
||||||
}
|
}
|
||||||
|
|
||||||
public func reloadData() {
|
public func reloadData() {
|
||||||
|
|||||||
@@ -241,13 +241,13 @@ extension DiffableDataSource {
|
|||||||
self.base?.moveRow(at: indexPath, to: newIndexPath)
|
self.base?.moveRow(at: indexPath, to: newIndexPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func performBatchUpdates(updates: () -> Void, animated: Bool) {
|
public func performBatchUpdates(updates: () -> Void, animated: Bool, completion: @escaping () -> Void) {
|
||||||
|
|
||||||
guard let base = self.base else {
|
guard let base = self.base else {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
base.performBatchUpdates(updates)
|
base.performBatchUpdates(updates, completion: { _ in completion() })
|
||||||
}
|
}
|
||||||
|
|
||||||
public func reloadData() {
|
public func reloadData() {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public protocol DiffableDataSourceTarget {
|
|||||||
/**
|
/**
|
||||||
Animates multiple insert, delete, reload, and move operations as a group.
|
Animates multiple insert, delete, reload, and move operations as a group.
|
||||||
*/
|
*/
|
||||||
func performBatchUpdates(updates: () -> Void, animated: Bool)
|
func performBatchUpdates(updates: () -> Void, animated: Bool, completion: @escaping () -> Void)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Reloads all sections and items.
|
Reloads all sections and items.
|
||||||
@@ -114,9 +114,15 @@ extension DiffableDataSource.Target {
|
|||||||
using stagedChangeset: Internals.DiffableDataUIDispatcher<O>.StagedChangeset<C>,
|
using stagedChangeset: Internals.DiffableDataUIDispatcher<O>.StagedChangeset<C>,
|
||||||
animated: Bool,
|
animated: Bool,
|
||||||
interrupt: ((Internals.DiffableDataUIDispatcher<O>.Changeset<C>) -> Bool)? = nil,
|
interrupt: ((Internals.DiffableDataUIDispatcher<O>.Changeset<C>) -> Bool)? = nil,
|
||||||
setData: (C) -> Void
|
setData: (C) -> Void,
|
||||||
|
completion: @escaping () -> Void
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
let group = DispatchGroup()
|
||||||
|
defer {
|
||||||
|
|
||||||
|
group.notify(queue: .main, execute: completion)
|
||||||
|
}
|
||||||
if self.shouldSuspendBatchUpdates, let data = stagedChangeset.last?.data {
|
if self.shouldSuspendBatchUpdates, let data = stagedChangeset.last?.data {
|
||||||
|
|
||||||
setData(data)
|
setData(data)
|
||||||
@@ -133,6 +139,7 @@ extension DiffableDataSource.Target {
|
|||||||
self.reloadData()
|
self.reloadData()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
group.enter()
|
||||||
self.performBatchUpdates(
|
self.performBatchUpdates(
|
||||||
updates: {
|
updates: {
|
||||||
|
|
||||||
@@ -206,7 +213,8 @@ extension DiffableDataSource.Target {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
animated: animated
|
animated: animated,
|
||||||
|
completion: group.leave
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,16 +59,14 @@ extension Internals {
|
|||||||
Target,
|
Target,
|
||||||
StagedChangeset<[Internals.DiffableDataSourceSnapshot.Section]>,
|
StagedChangeset<[Internals.DiffableDataSourceSnapshot.Section]>,
|
||||||
@escaping ([Internals.DiffableDataSourceSnapshot.Section]) -> Void
|
@escaping ([Internals.DiffableDataSourceSnapshot.Section]) -> Void
|
||||||
) -> Void,
|
) -> Void
|
||||||
completion: @escaping () -> Void
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
self.apply(
|
self.apply(
|
||||||
.init(),
|
.init(),
|
||||||
target: target,
|
target: target,
|
||||||
animatingDifferences: animatingDifferences,
|
animatingDifferences: animatingDifferences,
|
||||||
performUpdates: performUpdates,
|
performUpdates: performUpdates
|
||||||
completion: completion
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,8 +78,7 @@ extension Internals {
|
|||||||
Target,
|
Target,
|
||||||
StagedChangeset<[Internals.DiffableDataSourceSnapshot.Section]>,
|
StagedChangeset<[Internals.DiffableDataSourceSnapshot.Section]>,
|
||||||
@escaping ([Internals.DiffableDataSourceSnapshot.Section]) -> Void
|
@escaping ([Internals.DiffableDataSourceSnapshot.Section]) -> Void
|
||||||
) -> Void,
|
) -> Void
|
||||||
completion: @escaping () -> Void
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
self.dispatcher.dispatch { [weak self] in
|
self.dispatcher.dispatch { [weak self] in
|
||||||
@@ -112,7 +109,6 @@ extension Internals {
|
|||||||
#if canImport(QuartzCore)
|
#if canImport(QuartzCore)
|
||||||
|
|
||||||
CATransaction.begin()
|
CATransaction.begin()
|
||||||
CATransaction.setCompletionBlock(completion)
|
|
||||||
|
|
||||||
if !animatingDifferences {
|
if !animatingDifferences {
|
||||||
|
|
||||||
@@ -122,11 +118,9 @@ extension Internals {
|
|||||||
|
|
||||||
CATransaction.commit()
|
CATransaction.commit()
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
performDiffingUpdates()
|
performDiffingUpdates()
|
||||||
completion()
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user