👉🏻 Fotis demonstrates that using Vue with TypeScript brings many benefits.
👉🏻 With features like typed props, emits, slots, state management, and generics, it noticeably improves the readability of a codebase and ensures everything works as expected.
👉🏻 "In short words, we will be sending a request under the hood for the next resources so that when user clicks the load more button, they will instantly see the result."
Eager delay spinners are not a good user experience as they can make a snappy user interface feel slower. We can provide a better user experience (UX) by delaying spinners to appear only after a perceivable delay.
To achieve this improved UX, you can use AsyncComponent. Vue provides the defineAsyncComponentdefineAsyncComponent function to lazy load components:
1<template>2 <AsyncComp />3</template>45<script setup>6import { defineAsyncComponent } from 'vue'78const AsyncComp = defineAsyncComponent(() => {9 return new Promise((resolve, reject) => {10 // ...load component from server11 resolve(/* loaded component */)12 })13})14</script>
defineAsyncComponentdefineAsyncComponent accepts a loader function that returns a Promise. The resolveresolve callback should be called if the component has been loaded, and the rejectreject callback to indicate that loading the component has failed.
Now let's implement the delayed loading spinner by using the advanced options of the defineAsyncComponentdefineAsyncComponent function:
1<template>2 <AsyncComp />3</template>45<script>6import { defineAsyncComponent } from 'vue'7import Loading from './components/Loading'89export default {10 components: {11 AsyncComp: defineAsyncComponent({12 // the loader function13 loader: () =>14 new Promise((resolve) => {15 setTimeout(() => {16 resolve(import('./components/HelloWorld.vue'))17 }, 2000)18 }),1920 // A component to use while the async component is loading21 loadingComponent: Loading,22 // Delay before showing the loading component. Default: 200ms.23 delay: 500,24 }),25 },26 data() {},27}28</script>
This demo simulates a network request to fetch HelloWorld.vueHelloWorld.vue from a server which takes 2 seconds:
👉🏻 Ever wondered why cookies are not passed correctly to subrequests - e.g. during SSR or when using Nitro/H3?
👉🏻 Alexander takes a look at how to pass all the important information, including event context and headers to further calls, eliminating different behavior on server and client.
How's it going? I was planning to release the update for Reusable Components yesterday, but things haven't gone as planned. Instead, I will be launching it next week. I need a just a bit more time to make sure that the quality is up to my standards. As I've been updating the course and re-writing all the content and step-by-step refactorings, I've also been able to simplify a few things. It's just like refactoring a piece of code, and it's one of the greatest feelings. I also looked at how much content is in there, and it looks like it will be similar to the Clean Components Toolkit. Lots of great content on how to write highly reusable components, simplified and updated — I can't wait to release the update next week! Oh, and one more thing: I'm doing a podcast with Alex Lichter ! It's called Deja Vue and we'll be releasing the first ...
Tuesday, February 13, 2024 The News tab on the Scripting News home page was set up to request the All category from my FeedLand account. I switched to Tech, it's a bit faster, and probably a better fit. Still looking for a performance issue. # If you're thinking it might be good if President Biden stepped aside for someone younger and nicer to look at, what you really want is President Biden to be younger and nicer looking, and of course he probably wouldn't mind that either. But, as Keith Olbermann spells out so well in his latest Countdown , if he were to step aside that would basically concede the election to Trump. So if you think the old man is being silly and vain, well, he's being a lot smarter than you are, and btw, paying a huge price. If you live to be 81, I bet the last thing you want to do, after the life he's had, is to be in this position. We should get behind him, and tell him so, let him know we don't want anyone else, and we ...
评论
发表评论