feat: pipe only loads necessary dependencies #395
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.
When using multiple scopes, Transloco pipe will derive scope from the key and only load dependencies for that scope.
Closes #394
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #394
When using
multi
flag, Transloco flag will map over and load dependencies for all scopes in the ProviderScope array, even if those fetched translations aren't needed for the view currently rendered. This might result in performance issues due to unnecessary API calls.For example, the following component from the sample would only need translations for the
admin-page
scope, but the network tab shows that an unneeded call was also made forlazy-page
translations:What is the new behavior?
The Transloco pipe should derive the scope in question from the key passed in, then determine which scope to resolve by searching the ProviderScope array for a matching scope or alias name.
After these changes, we can see that the unneeded call for
lazy-page
translations is no longer made:Does this PR introduce a breaking change?
Other information