add cancellationToken to another override of PaginateAll

This commit is contained in:
Jonas Dellinger 2023-11-03 22:50:45 +01:00
parent 21d9a5ff16
commit 16d898b344
2 changed files with 8 additions and 4 deletions

View File

@ -120,13 +120,15 @@ namespace SpotifyAPI.Web
/// <param name="firstPage">A first page, will be included in the output list!</param> /// <param name="firstPage">A first page, will be included in the output list!</param>
/// <param name="mapper">A function which maps response objects to the next paging object</param> /// <param name="mapper">A function which maps response objects to the next paging object</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>
/// <typeparam name="TNext">The Response-Type</typeparam> /// <typeparam name="TNext">The Response-Type</typeparam>
/// <returns>A list containing all fetched pages</returns> /// <returns>A list containing all fetched pages</returns>
Task<IList<T>> PaginateAll<T, TNext>( Task<IList<T>> PaginateAll<T, TNext>(
IPaginatable<T, TNext> firstPage, IPaginatable<T, TNext> firstPage,
Func<TNext, IPaginatable<T, TNext>> mapper, Func<TNext, IPaginatable<T, TNext>> mapper,
IPaginator? paginator = default! IPaginator? paginator = default!,
CancellationToken cancellationToken = default!
); );
/// <summary> /// <summary>
@ -142,7 +144,7 @@ namespace SpotifyAPI.Web
IAsyncEnumerable<T> Paginate<T>( IAsyncEnumerable<T> Paginate<T>(
IPaginatable<T> firstPage, IPaginatable<T> firstPage,
IPaginator? paginator = default!, IPaginator? paginator = default!,
CancellationToken cancel = default! CancellationToken cancel = default
); );
/// <summary> /// <summary>

View File

@ -109,16 +109,18 @@ namespace SpotifyAPI.Web
/// <param name="firstPage">A first page, will be included in the output list!</param> /// <param name="firstPage">A first page, will be included in the output list!</param>
/// <param name="mapper">A function which maps response objects to the next paging object</param> /// <param name="mapper">A function which maps response objects to the next paging object</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>
/// <typeparam name="TNext">The Response-Type</typeparam> /// <typeparam name="TNext">The Response-Type</typeparam>
/// <returns>A list containing all fetched pages</returns> /// <returns>A list containing all fetched pages</returns>
public Task<IList<T>> PaginateAll<T, TNext>( public Task<IList<T>> PaginateAll<T, TNext>(
IPaginatable<T, TNext> firstPage, IPaginatable<T, TNext> firstPage,
Func<TNext, IPaginatable<T, TNext>> mapper, Func<TNext, IPaginatable<T, TNext>> mapper,
IPaginator? paginator = null IPaginator? paginator = null,
CancellationToken cancellationToken = default
) )
{ {
return (paginator ?? DefaultPaginator).PaginateAll(firstPage, mapper, _apiConnector); return (paginator ?? DefaultPaginator).PaginateAll(firstPage, mapper, _apiConnector, cancellationToken);
} }
private Task<T> FetchPage<T>(string? nextUrl) private Task<T> FetchPage<T>(string? nextUrl)