Repository navigation
Conversation
ModelType.getSnapshot looked up each property's observable twice: once with getAtom to report it observed, and again through getChildNode. Both return the same ObservableValue. Read the child node with raw() from the first lookup instead.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do and why?
For each property,
ModelType.getSnapshotcalledgetAtom(storedValue, name)to report it observed, thengetChildNode, which calls_getAdministrationand sogetAtomagain. Both return the sameObservableValue: every model property is anobservable.refon the instance. With MobX 7 each lookup costs several property reads.This PR reads the child node with
raw()from the first lookup, asgetChildNodedoes. The "Node not available" guard stays. Dependencies and snapshot values do not change.Benchmark: store with 10,000 todos (5 properties each).
doneon all 10k todos (one action)getSnapshot(store)Model snapshots > getSnapshot observes each property it reads: areactionongetSnapshot(m)must fire when a primitive changes and when a child model is replaced. It fails ifreportObserved()is removed orraw()is replaced byget(). It also passes on master (pure performance change).