Performance: Removed watchers and/or increased watchers specificity #1143
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.
Watchers can be expensive, especially when the object is a large array, or the watcher is "deep". Even inexpensive watchers can become create performance issues when you're dealing with a large number of the components within a view. This PR outright removes many watchers. Where watchers couldn't be removed, I was still able to increase the watchers specificity. For example, watching
$route
only to be checking a very specific param within the handler. It's better to just watch the specific param by watching$route.params.tenant
for example. Some watchers were replaced with computed variables to follow vue's suggestion that watchers be used for "side-effects of changing data". There are also some cases where I was able to use the watcher API to only temporarily watch a property instead of continuing to watch for the lifetime of the component. Together these changes should help improve performance of the system and also improve the clarity of the intent of watchers within these components.