-
Notifications
You must be signed in to change notification settings - Fork 93
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
refactor(utils): Replace GenRandomId
with getRandomId
#6425
base: next
Are you sure you want to change the base?
Conversation
8c8a1c6
to
a64d43a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the next
branch I'd prefer to use useId
: https://vuejs.org/api/composition-api-helpers.html#useid
It is Vue "native" way, and it's stable, unlinke Math.random()
.
The only problem is that it's uniq only in a single Vue package instance. For multiple apps on the page with multiple Vue it requires setting app.config.idPrefix
in an app.
For apps yes but for the library we can not be sure that the user has setup the id prefix correctly. One alternative would be to provide a custom
This could be used in the library while apps of course would just use |
- Use Typescript for correct type annotations - Fix length problem (the old implemenation sometimes did not yield the expected length, e.g. if a "short" random number was generated)¹ - Add unit test for the util ¹ Did some benchmarks: Just the method is now ~10% slower. But the old method delivered too short values for ~25% of all cases. Signed-off-by: Ferdinand Thiessen <[email protected]>
068c557
to
9d885b8
Compare
Simplified, what do you think? |
Since you've merged it, please don't forget to replace GenRandomId, after backport is there: https://github.com/nextcloud-libraries/nextcloud-vue/pull/6454/files#diff-c5595ba3afc4a147c5e8b442fe46ed5f41af898aad982d3b732103fe0fedb9f3R149 |
☑️ Resolves
¹ Did some benchmarks: Just the method is now ~10% slower. But the old method delivered too short values for ~25% of all cases.
🏁 Checklist
next
requested with a Vue 3 upgrade