Removed Irrelevant Cancelation Methods
Introduction:
In Atom 4, the underlying mechanism for handling data tasks has undergone a significant overhaul. Previous versions of Atom relied on URLDataTasks to manage network requests, which supported task cancellation through public methods exposed to clients. However, Atom 4 has transitioned to using an asynchronous version of the data function (async/await-compatible data(from:) method). This new approach leverages asynchronous programming paradigms to improve performance, readability, and maintainability.
A key consequence of this architectural shift is that task cancellation is no longer supported via public methods. In the URLDataTasks model, clients could explicitly cancel tasks using methods like cancel(), which was useful for scenarios such as aborting long-running network requests. In contrast, the asynchronous data function operates differently, with cancellation typically handled internally through mechanisms like Swift’s structured concurrency (e.g., Task cancellation) or cooperative cancellation patterns. These mechanisms are not exposed as public APIs in the same way, meaning clients cannot directly invoke cancellation through Atom’s public interface.
Motivation:
To avoid confusion and ensure a consistent developer experience, we must deprecate and remove the legacy task cancellation methods from Atom’s public API. Retaining these methods could mislead developers into expecting cancellation functionality that is no longer supported, potentially leading to errors, deprecated code usage, or incorrect assumptions about Atom’s behavior.
By removing these methods, we clarify that task cancellation is no longer a feature clients can rely on, aligning the API with the new asynchronous architecture.
Proposed Solution:
We removed the following method from Atom:
/// Cancels all currently running and suspended tasks.
///
/// Calling `cancelAllSessionTasks()` method will not invalide `URLSession`
/// instance nor will it empty cookies, cache or credential stores.
///
/// All subsequent tasks will occur on the same TCP connection.
public func cancelAllSessionTasks() async {
await service.cancelAllSessionTasks()
}Additional Info:
- Removed irrelevant methods to prevent confusion.
- Fixed Build Pre-action in the Example application.
- Updated documentation.
Tests:
N/A.
Source Compatibility:
Please check the box to indicate the impact of this proposal on source compatibility.
- This change is additive and does not impact existing source code.
- This change breaks existing source code.