question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Paging support: byPage not exposing settings parameter

See original GitHub issue

When generating an operation with paging, it mostly works well, except the byPage method that is generated does not pass the settings parameter down as defined on the PagedAsyncIterableIterator interface.

export interface PagedAsyncIterableIterator<T, PageT = T[], PageSettingsT = PageSettings> {
  next(): Promise<IteratorResult<T, T>>;
  [Symbol.asyncIterator](): PagedAsyncIterableIterator<T, PageT, PageSettingsT>;
  byPage: (settings?: PageSettingsT) => AsyncIterableIterator<PageT>;
}

Generate code:

public listAvailableWorkers(
    options?: RouterGetAvailableWorkersOptionalParams
  ): PagedAsyncIterableIterator<Worker> {
    const iter = this.getAvailableWorkersPagingAll(options);
    return {
      next() {
        return iter.next();
      },
      [Symbol.asyncIterator]() {
        return this;
      },
      byPage: () => {
        return this.getAvailableWorkersPagingPage(options);
      }
    };
  }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:28 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
MRayermannMSFTcommented, Nov 10, 2022

I rewrote your above example slightly in a way that I think shows what is going on a bit better. One of our struggles with pagination is that it’s not obvious that the list operation doesn’t return a promise…

Haha, I think when we migrated from the super old SDKs we just assumed methods named like list still returned promises. Thanks for pointing out where we can drop the some awaits.

Would calling it the last value produced by the byPage iterator be clearer? In pagination (and most iterators) we don’t use the return value feature of the iterator protocol.

Yes I think that would be clearer. Even more clearer would be if the comment put “value” and “byPage” in back-tics (`), and maybe even with a leading dot on “value”. So like:

/**
 * ...the last `.value` produced by the `byPage` iterator...
 */
function getContinuationToken() {}
1reaction
kazrael2119commented, Nov 3, 2022

Hi @MRayermannMSFT , The below is new sdk package azure-arm-resources-5.1.0.zip

We would like you help us verify whether the package works as your expected before release, you can also learn more by this pr: https://github.com/Azure/azure-sdk-for-js/pull/23688

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Paginating Requests in APIs. | Medium - Ignacio Chiazzo
When exposing large data sets through APIs, it needs to provide a mechanism to paginate ... SQL query generated by page-based pagination.
Read more >
Load and display paged data - Android Developers
The following example implements a PagingSource that loads pages of items by page number. The Key type is Int and the Value type...
Read more >
How to configure Spring boot pagination starting from page 1 ...
Just make oneIndexed parameter equals to true in your configuration file and pagination will start ... spring.data.web.pageable.one-indexed-parameters=true.
Read more >
Advanced Guide to Page View Tracking in Google Analytics 4
Learn how to properly track page view measurement in Google Analytics 4 (GA4). And get more insights through your page reporting.
Read more >
class WP_Query {} - WordPress Developer Resources
Post & Page Parameters. Display content based on post and page parameters. Remember that default post_type is only set to display posts but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found