Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination #111

Open
jedwards1211 opened this issue Jul 24, 2020 · 1 comment
Open

Pagination #111

jedwards1211 opened this issue Jul 24, 2020 · 1 comment

Comments

@jedwards1211
Copy link

jedwards1211 commented Jul 24, 2020

Off the top of your head, do you know if it would be possible to implement pagination when the user scrolls down far enough in the search results? Or is it impossible to get notified by inquirer that that's happened?

I want to make helpers for selecting AWS resources, and it would be nice to be able to use AWS pagination.

On the other hand, I want to cache and immediately show recent selections while new results are being fetched, which probably isn't possible with this...maybe I should make my own thing that doesn't rely on inquirer...

@mokkabonna
Copy link
Owner

mokkabonna commented Aug 23, 2020

I like the idea, but I don't think it is possible with the current API.

I guess you could do something like this:

Option 1
Option 2
Option 3
Select next page

where "select next page" could be any text, and we implemented support for when choosing any item, you can either return true to actually select the value of the item. Or you could return a promise, which would then be expected to return a new list of items.

This could be used for pagination up or down, or even more generically for some kind of arbitrarily deep folder structure.

{
      type: 'autocomplete',
      name: 'fruit',
      suggestOnly: true,
      message: 'What is your favorite fruit?',
      source: searchFood,
      pageSize: 4,
      selectItem: function (chosenValue) {
        if (chosenValue === 'folder-pictures') {
          return getSubFolder(chosenValue);
        } else if (chosenValue === 'next-page') {
          return getNextPage();
        } else {
          return true;
        }
      }
    },
}

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants