Hey,
I'm wrapping up work now and spending the rest of this year with my family.
Flying for the first time with my daughter! Hopefully that goes smoothly and isn't too much of an adventure.
I've been hard at work on the content for Composable Design Patterns, and I've got a batch of 4 more patterns nearly ready to go.
Here's a new article I wrote for you:
Scaling Your Vue App: 4 Proven Patterns to Keep It Clean
And of course, an awesome new episode of DejaVue, some tips, and some links.
Have a great week!
— Michael
Changes are really difficult to make if components have lots of dependencies on each other, or if they’re doing multiple things at once — often these issues come together.
If we can disentangle the spaghetti code we can make our lives a lot simpler.
Here’s how we can do this:
Did you know that you can easily check the version of Vue at runtime?
import { version } from 'vue';if (version.split('.')[0] === '2') {console.log('Uh, this app is gonna crash.');console.log('Upgrade to Vue 3!');}
Using async components is a great way to speed up the initial load time of your app.
It's pretty straightforward to use in Vue 3:
// Regular, synchronous componentimport MyComponent from './MyComponent.vue';// Loading it asynchronouslyimport { defineAsyncComponent } from 'vue';const AsyncComponent = defineAsyncComponent(() => import('./MyComponent.vue'));
Like other components, you can also register them globally:
app.component('AsyncComponent', defineAsyncComponent(() => import('~/components/MyComponent.vue'));
That's all there is to it. Seriously! Just use AsyncComponent
like any other component.
The syntax for Vue 2 is not that different, you just don't need to use a helper function:
const AsyncComponent = () => import('./components/LazyLoadingFTW.vue');
You can also provide a bunch of other options for async components, including:
onError
handlerIt also automatically hooks into the new suspense feature, which creates all sorts of magic.
Here are the docs for Vue 3 async components.
In this episode of DejaVue, Alex and Michael are joined by Sumit Kumar, the founder of Parqet.
Sumit shares his journey from getting into Web Development and Vue.js over to working at Stripe and eventually founding Parqet, a (German) portfolio tracker SaaS.
Topics covered in the first part of our conversation include a lot of business insights, such as the transition from being a developer to being a founder, the challenges and benefits of bootstrapping, as well as the importance of marketing.
Watch on YouTube or listen on your favorite podcast platform.
Chapters:
In case you missed them:
Learn how to write better composables in Vue. Use these seven patterns to manage state, logic, configuration, and input flexibility.
Check it out here: Composable Design Patterns in Vue
As your Vue app grows, it can become harder to keep it organized. Learn four proven patterns that help simplify data flow, testing, configuration, and flexibility, ensuring your code remains clean and scalable.
Check it out here: Scaling Your Vue App: 4 Proven Patterns to Keep It Clean
Here are some upcoming events you might be interested in. Let me know if I've missed any!
The biggest Vue conference in the world! A two-day event with workshops, speakers from around the world, and socializing.
A great Vue conference, this year held in Tampa. Two days of conference talks, plus a day for workshops.
"The first 90 percent of the code accounts for the first 90 percent of the development time. The remaining 10 percent of the code accounts for the other 90 percent of the development time." — Tom Cargill
The best way to commit something to long-term memory is to periodically review it, gradually increasing the time between reviews 👨‍🔬
Actually remembering these tips is much more useful than just a quick distraction, so here's a tip from a couple weeks ago to jog your memory.
If you've ever written unit tests, you'll have needed to mock out API endpoints that are used in your components or stores.
With @nuxt/test-utils
this is really simple, because you get the registerEndpoint
utility method:
import { registerEndpoint } from '@nuxt/test-utils/runtime';import userTestData from './userTestData.json';registerEndpoint('/users/', () => userTestData);// ...tests
You can mock any server route (API endpoint), including external endpoints if you need.
Michael Hoffman curates a fantastic weekly newsletter with the best Vue and Nuxt links.
p.s. I also have a bunch of products/courses: