Skip to content

Conversation

@MichaHuhn
Copy link
Contributor

Convert the URLManager class into a useUrl() 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:

const params = useUrlSearchParams('history')
const iconStore = useIconsStore()
const { downloadIcon } = useDownloadIcon()

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).

sebinside and others added 3 commits September 21, 2025 14:39
@sebinside sebinside deleted the branch sebinside:main December 13, 2025 23:54
@sebinside sebinside closed this Dec 13, 2025
@sebinside sebinside reopened this Dec 14, 2025
@sebinside sebinside deleted the branch sebinside:main December 14, 2025 00:08
@sebinside sebinside closed this Dec 14, 2025
@sebinside sebinside reopened this Dec 14, 2025
@sebinside sebinside changed the base branch from develop to main December 14, 2025 00:09
@sebinside sebinside added enhancement New feature or request support Does enhance the experience without changing the icon generator PR-planned Pull request with changes that are planned to be merged soon(ish) labels Jan 2, 2026
@sebinside sebinside merged commit 9daad47 into sebinside:main Jan 3, 2026
1 check passed
@MichaHuhn MichaHuhn deleted the refactor/convert-UrlManager-class-into-composable branch January 3, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR-planned Pull request with changes that are planned to be merged soon(ish) support Does enhance the experience without changing the icon generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants