Rename callback: to completion:

This commit is contained in:
Maurice Parker
2019-12-14 18:01:34 -07:00
parent 43bf65b7a6
commit 58b24f3349
26 changed files with 196 additions and 196 deletions

View File

@@ -58,8 +58,8 @@ final class DetailViewController: NSViewController, WKUIDelegate {
currentWebViewController = webViewController(for: mode)
}
func canScrollDown(_ callback: @escaping (Bool) -> Void) {
currentWebViewController.canScrollDown(callback)
func canScrollDown(_ completion: @escaping (Bool) -> Void) {
currentWebViewController.canScrollDown(completion)
}
override func scrollPageDown(_ sender: Any?) {

View File

@@ -127,9 +127,9 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
// MARK: Scrolling
func canScrollDown(_ callback: @escaping (Bool) -> Void) {
func canScrollDown(_ completion: @escaping (Bool) -> Void) {
fetchScrollInfo { (scrollInfo) in
callback(scrollInfo?.canScrollDown ?? false)
completion(scrollInfo?.canScrollDown ?? false)
}
}
@@ -227,7 +227,7 @@ private extension DetailWebViewController {
webView.evaluateJavaScript(render)
}
func fetchScrollInfo(_ callback: @escaping (ScrollInfo?) -> Void) {
func fetchScrollInfo(_ completion: @escaping (ScrollInfo?) -> Void) {
var javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: document.body.scrollTop}; x"
if #available(macOS 10.15, *) {
javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: window.pageYOffset}; x"
@@ -235,16 +235,16 @@ private extension DetailWebViewController {
webView.evaluateJavaScript(javascriptString) { (info, error) in
guard let info = info as? [String: Any] else {
callback(nil)
completion(nil)
return
}
guard let contentHeight = info["contentHeight"] as? CGFloat, let offsetY = info["offsetY"] as? CGFloat else {
callback(nil)
completion(nil)
return
}
let scrollInfo = ScrollInfo(contentHeight: contentHeight, viewHeight: self.webView.frame.height, offsetY: offsetY)
callback(scrollInfo)
completion(scrollInfo)
}
}

View File

@@ -595,19 +595,19 @@ private extension SidebarViewController {
return rowView.view(atColumn: 0) as? SidebarCell
}
func applyToAvailableCells(_ callback: (SidebarCell, Node) -> Void) {
func applyToAvailableCells(_ completion: (SidebarCell, Node) -> Void) {
outlineView.enumerateAvailableRowViews { (rowView: NSTableRowView, row: Int) -> Void in
guard let cell = cellForRowView(rowView), let node = nodeForRow(row) else {
return
}
callback(cell, node)
completion(cell, node)
}
}
func applyToCellsForRepresentedObject(_ representedObject: AnyObject, _ callback: (SidebarCell, Node) -> Void) {
func applyToCellsForRepresentedObject(_ representedObject: AnyObject, _ completion: (SidebarCell, Node) -> Void) {
applyToAvailableCells { (cell, node) in
if node.representsSidebarObject(representedObject) {
callback(cell, node)
completion(cell, node)
}
}
}

View File

@@ -1027,7 +1027,7 @@ private extension TimelineViewController {
return fetchedArticles
}
func fetchUnsortedArticlesAsync(for representedObjects: [Any], callback: @escaping ArticleSetBlock) {
func fetchUnsortedArticlesAsync(for representedObjects: [Any], completion: @escaping ArticleSetBlock) {
// The callback will *not* be called if the fetch is no longer relevant that is,
// if its been superseded by a newer fetch, or the timeline was emptied, etc., it wont get called.
precondition(Thread.isMainThread)
@@ -1038,7 +1038,7 @@ private extension TimelineViewController {
guard !operation.isCanceled, let strongSelf = self, operation.id == strongSelf.fetchSerialNumber else {
return
}
callback(articles)
completion(articles)
}
fetchRequestQueue.add(fetchOperation)
}