-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add weakMapMemoize utility. #26605
Add weakMapMemoize utility. #26605
Conversation
Deploy preview for dagit-core-storybook ready! ✅ Preview Built with commit 3715f68. |
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.
Cool, seems reasonable to me.
Summary & Motivation
Introduces a memoize function thats more powerful than what lodash offers. Lodash memoize only works with string keys, and so it requires you to take your arguments and somehow serialize it to a string. Depending on the object this can be very slow if the object is big. To avoid the headache of serialization I'm adding a weakMapMemoize which is much more flexible and can cache any function mixing both primitives and objects.
Going to use this to memoize the
filterByQuery
helpers for the GanttChart since it looks like we call the utility in a lot of different places separately and having them coordinate so that there's only 1 call is a bit tricky.How I Tested These Changes
jest tests