Created
April 12, 2024 06:47
-
-
Save dezinezync/9fc4fa19627085b5de9a7186ddf50e47 to your computer and use it in GitHub Desktop.
Sync Operation Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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