Closed Ryu0118 closed 1 year ago
Hi @Ryu0118, can you provide some examples of how you would use this tool? It doesn't seem too different from just doing this inline:
try await Task.sleep(for: .seconds(1))
await …
Further, using Task.delay
leads you to code that is difficult to test since a clock is not involved. It is better to do:
@Dependency(\.continuousClock) var clock
try await clock.sleep(for: .seconds(1))
await …
Also, spinning up unstructured tasks will mean losing out on cooperative cancellation, so you would want to bridge that too.
@Ryu0118 We're going to close this out for now, but if you follow up with some more info and motivation we can reconsider. Thanks for taking the time to PR!
I propose extensions to Task type that delay the execution of async operation.