Composables, assemble!
Let’s take a look at how we can leverage our composables and refactor the app to expand the functionalities a bit. Composables are all about reusability: it’s their superpower in the Vue space, so let’s put our previously created composable into action.
First, we will work on refactoring the useComics
composable, where we will lightly apply the clean code principles. In our context, this will translate to applying the single responsibility principle and writing small and cohesive functions with meaningful names.
Refactoring useComics
We’ll refactor in a non-destructive way too, leaving the existing useComic
composable functional until we’re ready to update that too.
We’ll first move the static constants out of the function to the upper scope. We’ll also import additional types that we will reference in functions. This way, we can still access them, but they are available throughout the file. I make...