-
Notifications
You must be signed in to change notification settings - Fork 405
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
perf(store): prevent initializing state factory at feature levels #2262
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 456efc0. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targetsSent with 💌 from NxCloud. |
commit: |
BundleMonFiles updated (1)
Unchanged files (5)
Total files change -1.04KB -0.8% Groups updated (2)
Final result: ✅ View report in BundleMon website ➡️ |
BundleMon (NGXS Plugins)Unchanged files (9)
No change in files bundle size Unchanged groups (1)
Final result: ✅ View report in BundleMon website ➡️ |
BundleMon (Integration Projects)Files updated (3)
Total files change -264B -0.13% Final result: ✅ View report in BundleMon website ➡️ |
7c5e5e9
to
23c9ff5
Compare
In this commit, we mark the state factory as a root provider to prevent its initialization at feature levels when `provideStates` is called. Previously, the state factory was initialized at feature levels because it needed to retrieve the feature-level injector in order to call `injector.get(FeatureStateClass)`. This was necessary because, when `NgxsModule.forFeature([BlogState])` was called, the `BlogState` instance could only be retrieved from the feature injector hierarchy. Now, since `addAndReturnDefaults` is called at the feature level inside the feature environment initializer, it is executed within the feature injection context, allowing us to use the `inject(...)` function directly.
23c9ff5
to
456efc0
Compare
Code Climate has analyzed commit 456efc0 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 95.3% (0.0% change). View more on Code Climate. |
In this commit, we mark the state factory as a root provider to prevent its initialization
at feature levels when
provideStates
is called.Previously, the state factory was initialized at feature levels because it needed to retrieve
the feature-level injector in order to call
injector.get(FeatureStateClass)
.This was necessary because, when
NgxsModule.forFeature([BlogState])
was called, theBlogState
instance could only be retrieved from the feature injector hierarchy.
Now, since
addAndReturnDefaults
is called at the feature level inside the feature environmentinitializer, it is executed within the feature injection context, allowing us to use the
inject(...)
function directly.