You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Perf] Do more diffing work on a background queue (#137)
This re-works `DiffableDataSource` to perform more operations on a
background thread — namely building the initial snapshot and searching
for items that need to be reconfigured.
In extremely large collections, performing these operations on the main
thread can produce noticeable lag.
### `Sendable` changes
This also makes `DiffableViewModel` inherit from `Sendable`, which means
this also applies to `CellViewModel`, `SupplementaryViewModel`,
`SectionViewModel`, and `CollectionViewModel`.
Early in development, I avoided doing this because I did not want to
place the burden of `Sendable` on clients. Instead, I opted to make
everything `@MainActor` (which is also a burden, in different ways).
However, that was changed in #135. After the performance improvements in
faabe72, making these types `Sendable`
is more necessary.
However, I think we can justify making all view models `Sendable`
because all the view models _should_ be stateless / immutable. If you
want to update the collection view, then you need to apply a new view
model via `update(viewModel:)` — so it's not as if you could be mutating
view model state outside of the `Driver` because those changes would not
be reflected anyway.
### Swift 6
The only issue with adopting Swift 6 right now is that
[`apply(_:animatingDifferences:completion:)`](https://developer.apple.com/documentation/uikit/uicollectionviewdiffabledatasource/3375795-apply)
is incorrectly marked as `@MainActor`, which becomes an error in Swift
6. See #116.
Otherwise, the library compiles successfully with Swift 6 and complete
concurrency checking. 🎉
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,14 @@ NEXT
7
7
8
8
- TBA
9
9
10
-
0.1.8 - NEXT
10
+
0.1.8
11
11
-----
12
12
13
13
- Allow setting a `UICollectionViewDelegateFlowLayout` object to receive flow layout events from the collection view. ([@jessesquires](https://github.com/jessesquires), [#134](https://github.com/jessesquires/ReactiveCollectionsKit/pull/134))
14
-
- Swift Concurrency improvements: `@MainActor` annotations have been removed from most top-level types and protocols, instead opting to apply `@MainActor` to individual members only where necessary. The goal is to impose fewer restrictions/burdens on clients. ([@jessesquires](https://github.com/jessesquires), [#135](https://github.com/jessesquires/ReactiveCollectionsKit/pull/135))
15
-
- Various performance improvements. ([@jessesquires](https://github.com/jessesquires), [#136](https://github.com/jessesquires/ReactiveCollectionsKit/pull/136), [@lachenmayer](https://github.com/lachenmayer), [#138](https://github.com/jessesquires/ReactiveCollectionsKit/pull/138))
14
+
- Swift Concurrency improvements:
15
+
-`@MainActor` annotations have been removed from most top-level types and protocols, instead opting to apply `@MainActor` to individual members only where necessary. ([@jessesquires](https://github.com/jessesquires), [#135](https://github.com/jessesquires/ReactiveCollectionsKit/pull/135))
16
+
-`DiffableViewModel` is now marked as `Sendable`. This means `Sendable` also applies to `CellViewModel`, `SupplementaryViewModel`, `SectionViewModel`, and `CollectionViewModel`. ([@jessesquires](https://github.com/jessesquires), [#137](https://github.com/jessesquires/ReactiveCollectionsKit/pull/137))
17
+
- Various performance improvements. Notably, when configuring `CollectionViewDriver` to perform diffing on a background queue via `CollectionViewDriverOptions.diffOnBackgroundQueue`, more operations are now performed in the background that were previously running on the main thread. ([@jessesquires](https://github.com/jessesquires), [#136](https://github.com/jessesquires/ReactiveCollectionsKit/pull/136), [#137](https://github.com/jessesquires/ReactiveCollectionsKit/pull/137), [@lachenmayer](https://github.com/lachenmayer), [#138](https://github.com/jessesquires/ReactiveCollectionsKit/pull/138))
0 commit comments