🔥 (#166) Design Patterns and Proxies
Hey all! I just finished adding some new design patterns and recording a bunch of new videos for Clean Components Toolkit. I'll be launching this update on June 5th, in two weeks, with a big discount. Of course, if you already own it, you'll see the update soon. I'm adding in three new design patterns, bringing the total up to 21. I've also recorded a bunch of extra "bonus" content. Enjoy your tips for this week! — Michael Vue Tips Collection 2Maybe you just want to stay on top of the latest features, remind yourself of interesting things Vue can do, and get daily inspiration. Vue Tips Collection is a beautiful book of 118 concise tips, as well as a daily email to get your creative juices flowing. 🔥 Proxy BasicsProxies are one of the strangest but most interesting parts of Javascript. It's a fancy wrapper that lets us create lightweight reactivity systems like in Vue, and so much more. Defining a proxy is simple. We just need to create a handler object, and then use it on an object: It lets us intercept property accesses with the get "trap", so we could force any object to use our own logging method: We can also intercept when a property is set, prototypes are accessed, and many more things. You can find a complete list on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy 🔥 Easily Mock API Routes in NuxtIf you've ever written unit tests, you'll have needed to mock out API endpoints that are used in your components or stores. With You can mock any server route (API endpoint), including external endpoints if you need. 🔥 Nuxt Plugin DependenciesWhen writing plugins for Nuxt, you can specify dependencies: But why do we need this? Normally, plugins are initialized sequentially — based on the order they are in the filesystem: But we can also have them loaded in parallel, which speeds things up if they don't depend on each other: However, sometimes we have other plugins that depend on these parallel plugins. By using the Although useful, you don't actually need this feature (probably). Pooya Parsa has said this:
🎧 Vue.js Amsterdam Recap (DejaVue #008)Alex and I recap the Amsterdam conference that happened back in February, now that the talks are up online. I wasn't able to make it, so he fills me in on all the details, and we talk about:
You can also watch or listen on any major platform. 📜 How do you structure a Vue project?Marco, a subscriber, once asked me this very question. My quick response was: keep it flat and simple, and when things start to get messy, slowly add in folders. An even better response: Markus wrote a great article on this, and he goes into much more detail and provides some more specific advice. Check it out here: Vue Project Directory Structure 💬 The Best Learners"The best learners are the people who push through the discomfort of being objectively bad at something." — Tommy Collison 🧠 Spaced-repetition: Handle Client-side Errors in NuxtThe 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. Proper error handling is a crucial part of any production app, even if it isn't the most exciting thing. Nuxt 3 comes with the Use the If we pass the Use a In some cases, a more drastic action might be needed, like navigating to a safe page using the You can place This is better than simply having a generic error message that's shown no matter what the error is. By isolating errors with Learn more from the docs: https://nuxt.com/docs/api/components/nuxt-error-boundary
|
评论
发表评论