From 777457e2858c42bcbd6e301bc1e7a3469083707b Mon Sep 17 00:00:00 2001 From: Andy Pack Date: Sun, 24 Sep 2023 18:30:05 +0100 Subject: [PATCH 1/2] adding cancellation token in SpotifyClient::PaginateAll and passing to IPaginator --- SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs | 2 +- SpotifyAPI.Web/Clients/SpotifyClient.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs b/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs index 4dca71c00..f7fa439ec 100644 --- a/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs +++ b/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs @@ -107,7 +107,7 @@ public interface ISpotifyClient /// Optional. If not supplied, DefaultPaginator will be used /// The Paging-Type /// A list containing all fetched pages - Task> PaginateAll(IPaginatable firstPage, IPaginator? paginator = default!); + Task> PaginateAll(IPaginatable firstPage, IPaginator? paginator = default!, CancellationToken cancellationToken = default); /// /// Fetches all pages and returns them grouped in a list. diff --git a/SpotifyAPI.Web/Clients/SpotifyClient.cs b/SpotifyAPI.Web/Clients/SpotifyClient.cs index d291a261b..032f2ca73 100644 --- a/SpotifyAPI.Web/Clients/SpotifyClient.cs +++ b/SpotifyAPI.Web/Clients/SpotifyClient.cs @@ -93,9 +93,9 @@ public SpotifyClient(SpotifyClientConfig config) /// Optional. If not supplied, DefaultPaginator will be used /// The Paging-Type /// A list containing all fetched pages - public Task> PaginateAll(IPaginatable firstPage, IPaginator? paginator = null) + public Task> PaginateAll(IPaginatable firstPage, IPaginator? paginator = null, CancellationToken cancellationToken = default) { - return (paginator ?? DefaultPaginator).PaginateAll(firstPage, _apiConnector); + return (paginator ?? DefaultPaginator).PaginateAll(firstPage, _apiConnector, cancellationToken); } /// From b30c96ff918a498ad18c7f2069729b14ab4883d3 Mon Sep 17 00:00:00 2001 From: Andy Pack Date: Sun, 24 Sep 2023 18:37:31 +0100 Subject: [PATCH 2/2] adding docstring for cancellation token --- SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs | 1 + SpotifyAPI.Web/Clients/SpotifyClient.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs b/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs index f7fa439ec..ed5d267eb 100644 --- a/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs +++ b/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs @@ -105,6 +105,7 @@ public interface ISpotifyClient /// /// The first page, will be included in the output list! /// Optional. If not supplied, DefaultPaginator will be used + /// The cancellation-token to allow to cancel the request. /// The Paging-Type /// A list containing all fetched pages Task> PaginateAll(IPaginatable firstPage, IPaginator? paginator = default!, CancellationToken cancellationToken = default); diff --git a/SpotifyAPI.Web/Clients/SpotifyClient.cs b/SpotifyAPI.Web/Clients/SpotifyClient.cs index 032f2ca73..93c8b54d2 100644 --- a/SpotifyAPI.Web/Clients/SpotifyClient.cs +++ b/SpotifyAPI.Web/Clients/SpotifyClient.cs @@ -91,6 +91,7 @@ public SpotifyClient(SpotifyClientConfig config) /// /// The first page, will be included in the output list! /// Optional. If not supplied, DefaultPaginator will be used + /// The cancellation-token to allow to cancel the request. /// The Paging-Type /// A list containing all fetched pages public Task> PaginateAll(IPaginatable firstPage, IPaginator? paginator = null, CancellationToken cancellationToken = default)