Skip to content

Commit

Permalink
Cancellation token in SpotifyClient::PaginateAll for passing to Pagin…
Browse files Browse the repository at this point in the history
…ator (#907)

* adding cancellation token in SpotifyClient::PaginateAll and passing to IPaginator

* adding docstring for cancellation token
  • Loading branch information
Sarsoo authored Nov 3, 2023
1 parent d8ca3b5 commit fdde87e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ public interface ISpotifyClient
/// </summary>
/// <param name="firstPage">The first page, will be included in the output list!</param>
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
/// <param name="cancellationToken">The cancellation-token to allow to cancel the request.</param>
/// <typeparam name="T">The Paging-Type</typeparam>
/// <returns>A list containing all fetched pages</returns>
Task<IList<T>> PaginateAll<T>(IPaginatable<T> firstPage, IPaginator? paginator = default!);
Task<IList<T>> PaginateAll<T>(IPaginatable<T> firstPage, IPaginator? paginator = default!, CancellationToken cancellationToken = default);

/// <summary>
/// Fetches all pages and returns them grouped in a list.
Expand Down
5 changes: 3 additions & 2 deletions SpotifyAPI.Web/Clients/SpotifyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ public SpotifyClient(SpotifyClientConfig config)
/// </summary>
/// <param name="firstPage">The first page, will be included in the output list!</param>
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
/// <param name="cancellationToken">The cancellation-token to allow to cancel the request.</param>
/// <typeparam name="T">The Paging-Type</typeparam>
/// <returns>A list containing all fetched pages</returns>
public Task<IList<T>> PaginateAll<T>(IPaginatable<T> firstPage, IPaginator? paginator = null)
public Task<IList<T>> PaginateAll<T>(IPaginatable<T> firstPage, IPaginator? paginator = null, CancellationToken cancellationToken = default)
{
return (paginator ?? DefaultPaginator).PaginateAll(firstPage, _apiConnector);
return (paginator ?? DefaultPaginator).PaginateAll(firstPage, _apiConnector, cancellationToken);
}

/// <summary>
Expand Down

0 comments on commit fdde87e

Please sign in to comment.