I'm using a dataTaskPublisher
to fetch some data:
func downloadData(_ req: URLRequest) {
self.cancelToken = dataTaskPublisher(for: req).sink { /* ... */ }
}
If the function is called while the request is in progress, I would like to return.
Currently I either:
1. Set the cancelToken
to nil in the sink or
2. Crate and manage a isDownloading
variable.
Is there a built-in way to check if the dataTaskPublisher
is running (and optionally its progress)?