You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I understand i.e parsing of results is not part of cancellable code which means that if searchTask is cancelled (i.e when query is cleared and result is immediately set to empty list) in a middle of parsing it will assign result after parsing is done, thus overriding previously set result.
Shouldn't this be done this way?
letnewResult=awaitsearchBooks(matching: searchTerm)if !Task.isCancelled {
result = newResult
isSearching =false}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, thanks for the very informative blog post, but one question is still bothering me:
Re https://github.com/peterfriese/SwiftUI-Concurrency-Essentials/blob/main/TaskCancellation/TaskCancellation/Views/BookSearchTaskCancellationView.swift#L41
Shouldn't result be assigned only after checking if task was not cancelled?
As I understand i.e parsing of results is not part of cancellable code which means that if searchTask is cancelled (i.e when query is cleared and result is immediately set to empty list) in a middle of parsing it will assign result after parsing is done, thus overriding previously set result.
Shouldn't this be done this way?
Beta Was this translation helpful? Give feedback.
All reactions