refactor: convert URLManager class into useUrl() composable
#376
+36
−33
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.
Convert the
URLManagerclass into auseUrl()composable.In this case we should use a composable instead of a class because we are using Vue code in the
URLManager.TypeScript classes or normal functions can be used if they don't need to interact with Vue code.
As soon as we interact with Vue code (ref, watch, VueUse or custom composables, etc), we should put the code into components or custom composables.
With this approach, the Vue code and reactive stuff will be registered synchronously and therefore will be cleaned up correctly by Vue and there won't be any surprises
skateFONT.However, if Vue code is called outside components or composables, it might not be tracked or cleaned up correctly because this Vue code migh not be executed in the "Vue scope" but in normal TS classes or functions.
The functions which are not returned inside the composable where the private methods before.
Because they are not returned, they are still private, so we get the same benefits here.
The following code is now only executed once:
Before, this code was executed many times in multiple places which could potentially lead to unwanted behavior because composables should only be instantiated once (per file).