Skip to content

Instantly share code, notes, and snippets.

@dezinezync
Created April 12, 2024 06:47
Show Gist options
  • Save dezinezync/9fc4fa19627085b5de9a7186ddf50e47 to your computer and use it in GitHub Desktop.
Save dezinezync/9fc4fa19627085b5de9a7186ddf50e47 to your computer and use it in GitHub Desktop.
Sync Operation Example
final class SyncOperation: OperationSuperclass {
public override func run() {
print("Sync has started")
Task { [weak self] in
guard let self else {
return
}
do {
try await runAsync()
}
catch {
print("error during sync: \(error)")
}
self.cleanupAndComplete()
}
}
fileprivate func runAsync() async throws {
try await syncFeedsAndFolders()
try await syncReadStates()
try await syncArticles()
try await syncBookmarks()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment