-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(iOS): restructure background task #424
Conversation
fun startSingleRun(spec: RunSpecification) { | ||
val startDateTime = NSDate() | ||
val differed = CoroutineScope(Dispatchers.Default).async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean deferred
? 😄
// End the task if time expires. | ||
UIApplication.shared.endBackgroundTask(self.backgroundTask) | ||
self.backgroundTask = UIBackgroundTaskIdentifier.invalid | ||
cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call it onCancel
? The first time I read it I thought it was a method to cancel the task, instead of an event callback.
differed.start() | ||
}, cancel = { | ||
differed.cancel() | ||
Logger.i { "Job cancelled after ${NSDate().timeIntervalSinceDate(startDateTime)} ms" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logger.i
will only log as a breadcrumb. This only gets sent if there's an error. Or will we always call line 26 inside the catch
when it's aborted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope only on error.
Closes #399