mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Serialize access to the UITableView for scrolling and diffable datasource updates. Issue #1806
This commit is contained in:
39
iOS/MasterFeed/MasterFeedDataSourceOperation.swift
Normal file
39
iOS/MasterFeed/MasterFeedDataSourceOperation.swift
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// MasterFeedDataSourceOperation.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Maurice Parker on 2/23/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RSCore
|
||||
import RSTree
|
||||
|
||||
class MasterFeedDataSourceOperation: MainThreadOperation {
|
||||
|
||||
// MainThreadOperation
|
||||
public var isCanceled = false
|
||||
public var id: Int?
|
||||
public weak var operationDelegate: MainThreadOperationDelegate?
|
||||
public var name: String? = "MasterFeedDataSourceOperation"
|
||||
public var completionBlock: MainThreadOperation.MainThreadOperationCompletionBlock?
|
||||
|
||||
private var dataSource: UITableViewDiffableDataSource<Node, Node>
|
||||
private var snapshot: NSDiffableDataSourceSnapshot<Node, Node>
|
||||
private var animating: Bool
|
||||
|
||||
init(dataSource: UITableViewDiffableDataSource<Node, Node>, snapshot: NSDiffableDataSourceSnapshot<Node, Node>, animating: Bool) {
|
||||
self.dataSource = dataSource
|
||||
self.snapshot = snapshot
|
||||
self.animating = animating
|
||||
}
|
||||
|
||||
func run() {
|
||||
dataSource.apply(snapshot, animatingDifferences: animating) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user