weakpoint | static slideshow generator
kandi X-RAY | weakpoint Summary
kandi X-RAY | weakpoint Summary
WeakPoint is a static slideshow generator.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of weakpoint
weakpoint Key Features
weakpoint Examples and Code Snippets
Community Discussions
Trending Discussions on weakpoint
QUESTION
I am part of a small team working on a fairly small website with user accounts; there are about 100 users at this time. And we are using Amazon Cognito for user management. On our website there is a summary page which displays a list/table of all users and various attributes. However, there's a hard limit on the number of items returned by the Amazon Cognito listUsers API call, in this case 60.
Luckily, the API call also returns a token to use to make subsequent calls if there are more users. Using those tokens, we're able to request a full list of all users.
Also, our website uses react-redux & the javascript library bluebird. In the context of this question, the component requesting a list of all users also dispatches actions (redux piece) and the CognitoIdentityServiceProvider from Amazon's aws-sdk is passed to bluebird Promise.promisfyAll (adds the async postfix to the listUser call). I am modifying this component to get the entire list of users.
As a rough draft of requesting the entire list of users, I used a recursive function to chain promises together until the pagination token returned from Amazon is undefined and store the results in some class variables. I used this forum post as reference.
This works but I don't feel great about the implementation; it should be okay for now in our use case as we have about 100 users but I do not know if this will scale well to thousands of users or more. I understand recursion just enough to be dangerous in that I do not know if this technique can cause problems when the number of promises/calls goes up. Questions of overhead and memory management come to mind. However, we shouldn't have to worry about the number of users skyrocketing into the thousands for at least a little while but I still want to learn about potentially preferable and/or safer methods of achieving the same thing.
The following snippets are from the component requesting the list of users:
...ANSWER
Answered 2019-Jan-16 at 14:49I understand recursion just enough to be dangerous in that I do not know if this technique can cause problems when the number of promises/calls goes up. Questions of overhead and memory management come to mind
Recursive approaches to make promise calls like your getUserList
are OK.
The only possible memory problem is that your allUsersTemp
array could be growing very large, until it exceeds the limits of your browser. You should however wonder long before that whether it would really be useful to display hundredths of thousands of user entries in a single large table. At those scales where memory would become problematic, you'd need more effective tools to manage your user base anyway than just listing all of them.
Regarding code style, I would recommend not to declare allUsersTemp
and paginationToken
as mutable higher-scope variables. Instead make them parameters of your recursive function and fulfill the promise with the result:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install weakpoint
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page