Cancellation support for Android/iOS #2
-
I still didn't understand the fact that cancellation does not work on platforms other than web. Dio supports cancellation on other platforms as well, why doesn't it work here? Can you help me understand this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @shrijanRegmi, |
Beta Was this translation helpful? Give feedback.
-
@JaffaKetchup, quick note on the impact of DIO request cancellation on iOS/ Android platforms (i.e. non-web): they benefit just like web, because - if I understand this correctly - DIO used to create a new HttpClient for each CancelToken and then force-closed that HttpClient along with all underlying resources. Understand they now moved to HttpClientRequest.abort(), which should have the same effect. This means no more resources like CPU, memory, data, battery wasted on IO, downloading tiles nobody needs on iOS/ Android also. Less visible than on web, but surely beneficial. Could be fun to count how large an impact that has in terms on KB not downloaded. |
Beta Was this translation helpful? Give feedback.
Hi @shrijanRegmi,
Technically, all platforms support cancellation of HTTP requests. However, AFAIK, the effect/advantage is only visible on the web.
This is because the web has a limit on the number of simultaneous requests, and so unnecessary requests delay required requests without cancelling. As far as I understand, this isn't an issue on other platforms.