PaginatedMessage to fetch data on demand
Is there an example on how to make a PaginatedMessage fetch data for a page when it is called? I dont want to get all the data from the db at once since its too slow.
8 Replies
There is LazyPaginatedMessage
This is a LazyPaginatedMessage. Instead of resolving all pages that are functions on PaginatedMessage.run will resolve when requested.
It’s not greatest way and it’s probably not what you want
But still much better than normal PaginatedMessage
You probahly want dynamic paginated message but sadly it’s not available on SapphireCorrect me if I'm wrong but I believe you're saying this because of the discussion we had in the past and even then I also said you were wrong and LazyPaginatedMessage is the correct thing to be used here but I don't think I got my message across then either and that's biting us in the back now :\
LazyPaginatedMessage is okay, and 100% can be used, but the problem is that I will still have all those functions in pages array
DynamicPaginatedMessage calls one function with currentPage parameter and gets data for that page only when page is changed
Only ONE function
With lazy it can be 1000 functions because there are 1000 pages
and there is nothing wrong with that. That is perfectly normal JavaScript code.
used to be classes were glorified functions and any methods on classes were functions on functions on functions so I hardly see the problem here
at any rate, you're free to publish your DynamicPaginatedMessage as your own package but I don't think we'll want to merge it to main for sapphire (not that there is a PR for it now anyway)
👍