-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Milestone
Description
It's a common task for Teller users to run iOS background fetch with Teller repositories so that they can keep repository data always up-to-date.
The current method is hands on and a roadblock for devs. It requires some work:
extension AppDelegate {
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
let backgroundFetchResult = Wendy.shared.backgroundFetchRunTasks(application, performFetchWithCompletionHandler: completionHandler)
// ??? What do we do about other SDKs that run background commands and return a UIBackgroundFetchResult?
// ??? What should a Teller repository sync return as a UIBackgroundFetchResult? Currently, it's up to the developer to implement this themselves.
repositorySyncService.sync { (success) in
completionHandler(backgroundFetchResult)
}
}
}
import RxSwift
protocol RepositorySyncService {
func sync(onComplete: @escaping (_ success: Bool) -> Void)
}
class TellerRepositorySyncService: RepositorySyncService {
private let reposRepository: ReposRepository
private let githubUsernameRepository: GitHubUsernameRepository
private let disposeBag = DisposeBag()
init(reposRepository: ReposRepository,
githubUsernameRepository: GitHubUsernameRepository) {
self.reposRepository = reposRepository
self.githubUsernameRepository = githubUsernameRepository
}
func sync(onComplete: @escaping (_ success: Bool) -> Void) {
if let usernameReposToFetch = githubUsernameRepository.dataSource.value {
reposRepository.requirements = ReposDataSource.GetDataRequirements(githubUsername: usernameReposToFetch)
try! reposRepository.refresh(force: false)
.subscribe(onSuccess: { (result) in
onComplete(result.didSucceed())
}).disposed(by: disposeBag)
}
}
}As you can see from the example above, there are some problems currently:
- What do developers do when trying to combine 2+ separate UIBackgroundFetchResult?
- Teller does not provide a way to create a UIBackgroundFetchResult for you. You must do it yourself. It would be great to do this work for you.
Metadata
Metadata
Assignees
Labels
No labels