Replace detached tasks with Task.dispatch(on:) (#201)

* Use Task.detach(on:) everywhere that was blocking.
* Don't wrap the continuations in a Task 🤦‍♂️
* Add sendable requirement to closure.
This commit is contained in:
Doug
2022-09-21 17:50:15 +01:00
committed by GitHub
parent 60f0f1605b
commit 8462862afc
9 changed files with 125 additions and 130 deletions
@@ -23,9 +23,9 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
private let linkColor = UIColor.blue
func fromPlain(_ string: String?) async -> AttributedString? {
await Task.detached {
await Task.dispatch(on: .global()) {
fromPlain(string)
}.value
}
}
func fromPlain(_ string: String?) -> AttributedString? {
@@ -41,9 +41,9 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
}
func fromHTML(_ htmlString: String?) async -> AttributedString? {
await Task.detached {
await Task.dispatch(on: .global()) {
fromHTML(htmlString)
}.value
}
}
// Do not use the default HTML renderer of NSAttributedString because this method