From fdde87e4760c3554b4c82c0b59084f1b22ba10b4 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 3 Nov 2023 21:43:45 +0000 Subject: [PATCH] Cancellation token in SpotifyClient::PaginateAll for passing to Paginator (#907) * adding cancellation token in SpotifyClient::PaginateAll and passing to IPaginator * adding docstring for cancellation token --- SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs | 3 ++- SpotifyAPI.Web/Clients/SpotifyClient.cs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs b/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs index 4dca71c0..ed5d267e 100644 --- a/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs +++ b/SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs @@ -105,9 +105,10 @@ namespace SpotifyAPI.Web /// /// 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!); + 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 d291a261..93c8b54d 100644 --- a/SpotifyAPI.Web/Clients/SpotifyClient.cs +++ b/SpotifyAPI.Web/Clients/SpotifyClient.cs @@ -91,11 +91,12 @@ namespace SpotifyAPI.Web /// /// 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) + public Task> PaginateAll(IPaginatable firstPage, IPaginator? paginator = null, CancellationToken cancellationToken = default) { - return (paginator ?? DefaultPaginator).PaginateAll(firstPage, _apiConnector); + return (paginator ?? DefaultPaginator).PaginateAll(firstPage, _apiConnector, cancellationToken); } ///