Skip to content
New issue

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

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

Already on GitHub? # to your account

Is there a way to dynamically configure the size? #128

Open
mfbx9da4 opened this issue May 18, 2022 · 7 comments
Open

Is there a way to dynamically configure the size? #128

mfbx9da4 opened this issue May 18, 2022 · 7 comments
Assignees
Labels

Comments

@mfbx9da4
Copy link

No description provided.

@medikoo
Copy link
Owner

medikoo commented May 26, 2022

@mfbx9da4 can you describe the use case?

@mfbx9da4
Copy link
Author

Suppose you have a list of items. Each item has some derived data which you would like to cache so that stays referentially identical to avoid unnecessary re-renders in React. The number of items to cache will depend on the user and will change over time. It's easy to know how big that list is at runtime and therefore trivial to know how big that cache size should be but impossible to have a good default size up front.

@medikoo
Copy link
Owner

medikoo commented May 26, 2022

@mfbx9da4 This looks to me as a use case that's best served by weak map based configuration.

So the cache is attached to an item, and if that item is disposed, then derived data you cached for it will also be disposed

@mfbx9da4
Copy link
Author

WeakMap is not available in react native

@medikoo
Copy link
Owner

medikoo commented May 26, 2022

WeakMap is not available in react native

What do you mean? WeakMap is a native JavaScript interface and this is a package that requires the JavaScript runtime to be run

@mfbx9da4
Copy link
Author

mfbx9da4 commented Jun 5, 2022

Although I haven't tested myself I saw this comment "WeakRef is not supported in Hermes or JSC on Android". I believe them!

@medikoo
Copy link
Owner

medikoo commented Jun 7, 2022

@mfbx9da4 memoizee under the hook doesn't use WeakRef but WeakMap, which as I search seems supported by all engines

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

No branches or pull requests

2 participants