-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
duplicate map.get() causes duplicate observers? #250
Comments
in general there is not much need to optimize those calls away. in the map example both entries are needed because a and b can be changed independently. the sorting might be a lot more efficient if you slice the list first. probably that should be a standard optimization. mobx does by default a lot of feed deduplication in the observers list. see observable.ts |
Thanks! I'll try slicing the array - though in my case it's just an array of keys and I look up the fields to sort by in an observable map. I'll build an array with all the fields pre-looked up before calling sort on it. Btw I tried to build mobx with a change to do a lookup of observable.id before adding it to |
Haha yeah I tried that as well a while back. I'm thinking of doing something more smart in the future, change the observers storage strategy from array to object if the list becomes too long or something similar :) It is a fully internal concept, so a lot of tweaks can be done in this area |
here's a small example:
output:
Should we avoid calling .get() more than once within the same derivation? That might be difficult if it calls other functions which might
get
the same data.I had a React component that observed & sorted 1000 items, and when it was unmounting, the root map had around 200K observers (so unmounting took a while).
The text was updated successfully, but these errors were encountered: