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
This commit is contained in:
andy 2023-11-03 21:43:45 +00:00 committed by GitHub
parent d8ca3b5d6d
commit fdde87e476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -105,9 +105,10 @@ namespace SpotifyAPI.Web
/// </summary> /// </summary>
/// <param name="firstPage">The first page, will be included in the output list!</param> /// <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="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> /// <typeparam name="T">The Paging-Type</typeparam>
/// <returns>A list containing all fetched pages</returns> /// <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> /// <summary>
/// Fetches all pages and returns them grouped in a list. /// Fetches all pages and returns them grouped in a list.

View File

@ -91,11 +91,12 @@ namespace SpotifyAPI.Web
/// </summary> /// </summary>
/// <param name="firstPage">The first page, will be included in the output list!</param> /// <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="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> /// <typeparam name="T">The Paging-Type</typeparam>
/// <returns>A list containing all fetched pages</returns> /// <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> /// <summary>