Javascript is required
Weekly Vue News Logo Weekly Vue News

Hi 👋

I want to apologize to everybody that received last week's issue twice... The corresponding AWS lambda function ran out of memory, and I had to retrigger it with increased memory (from 1GB to 2GB)... Let's cross our fingers that this is enough memory until we reach 1000 subscribers 🤞🏻😄 I further increased it to 4GB, just to be on the safe side 🙃

I think I now fixed most of the styling issues Gmail & Outlook users had with my emails. If you still encounter styling problems, reply to this email and let me know what problems you see and which email client you use. If you encounter massive styling issues, you can always view the issue online.

Styling HTML emails is such a pain... My biggest pain points:

Anyways: I'm still available for freelance projects, contact me if you want to work with me.

Have a nice week ☀️


Vue Tip: Typing Component Events

Watch on YouTube

To declare emits with full type inference support, we can use the defineEmits API, which is automatically available inside <script setup>:

<script setup>
const emit = defineEmits(['change', 'delete'])
</script>

defineEmits is a compiler macro only usable inside <script setup>. It does not need to be imported and is compiled away when <script setup> is processed. defineEmits provide proper type inference based on the options passed.

Using TypeScript, it is also possible to declare props and emits using pure type annotations:

<script setup>
const emit = defineEmits<{
(e: 'change', id: number): void
(e: 'delete', value: string): void
}>()
</script>

defineEmits can only use either runtime declaration OR type declaration. Using both at the same time will result in a compile error.

Warning

Currently, complex types and type imports from other files are not supported.

The type declaration argument must be one of the following to ensure correct static analysis:

  • A type literal
  • A reference to an interface or a type literal in the same file

Curated Vue Content

📕 Vue skills to master in 2023

👉🏻 This article serves as your guide to the hot topics, tools and trends that you can stay on top of to elevate your code and level up your life.

www.vuemastery.com
📕 What is changing for Vuejs developers in 2023

👉🏻 Vite, VueUse, Pinia, TypeScript for Vue.js, the Composition API, Vitest, Nuxt 3!

vueschool.io
📕 Improving Reactivity with VueUse

👉🏻 Charles explores some of the VueUse utilities to help us improve reactivity in our Vue 3 application.

vueschool.io
📕 Nuxt 3 Migration Simplified: A Cheat Sheet
👉🏻 Upgrading to Nuxt 3 from Nuxt 2 can be a little intimidating.
👉🏻 Harlan wrote this cheat sheet to simplify the upgrade process for himself and "for others who are brave enough to tackle it".
harlanzw.com
📕 Build a streaming platform

👉🏻 In this tutorial, you learn how to build a live streaming application with with Vue.js and Go that displays the online status of users you are interested in and who are currently streaming a video.

pusher.com

Quote of the week

Quote of the week

JavaScript Tip: Replace Switch Statements With Object Literals

Watch on YouTube

I'm not a big fan of JavaScript's switch statement. Its syntax is hard to remember and can cause tricky bugs if you forget to add a break statement for every case.

Let's take a look at an example:

const getRole = (id) => {
switch (id) {
case 11:
return 'ADMIN'
case 22:
return 'OPERATOR'
default:
return 'USER'
}
}

I prefer using JavaScript's object literals over switch statements as the code is faster, more readable, and less verbose.

For each case we would have in the switch statement, we need to define an object key for each case:

const getRole = (id) => {
const rolesMap = {
11: 'ADMIN',
22: 'OPERATOR',
33: 'USER',
}
return rolesMap[id]
}

Finally, let's handle the default case of the switch statement by adding a default key:

const getRole = (id) => {
const defaultKey = 33
const rolesMap = {
11: 'ADMIN',
22: 'OPERATOR',
33: 'USER',
}
return rolesMap[id] ?? rolesMap[defaultKey]
}

We try to access the value using rolesMap[id] and use the nullish coalescing operator (??) to set the default value if the value is undefined or null.

Curated Web Development Content

📕 JavaScript Frameworks - Heading into 2023

👉🏻 Ryan Carniato ponders where JS frameworks are headed in 2023.

dev.to
📕 Notable improvements to Web Components in 2022

👉🏻 Serhii Kulykov wrote a review of the notable improvements to Web Components in 2022.

webcomponents.today
📕 Awesome ChatGPT
👉🏻 This repository contains a curated list of resources for ChatGPT and GPT-3.
👉🏻 It includes general resources, API tools, Chrome extensions, CLI tools, and more.
github.com
📕 Patterns.dev
👉🏻 A free book you can download in PDF format or enjoy on the web.
👉🏻 Learn about lots of fundamentals, from how different styles of rendering or importing resources work to performance optimizations and case studies.
www.patterns.dev
🛠️ Pirate Weather

👉🏻 A free and open weather forecast API that was built as a compatible alternative to the Dark Sky API.

pirateweather.net
Warning
Expect styling problems, as this issue was created using a different rendering mechanism.
Published at Jan 16, 2023, 2:00 PM
I will never share any of your personal data.

Hi 👋

I want to apologize to everybody that received last week's issue twice... The corresponding AWS lambda function ran out of memory, and I had to retrigger it with increased memory (from 1GB to 2GB)... Let's cross our fingers that this is enough memory until we reach 1000 subscribers 🤞🏻😄 I further increased it to 4GB, just to be on the safe side 🙃

I think I now fixed most of the styling issues Gmail & Outlook users had with my emails. If you still encounter styling problems, reply to this email and let me know what problems you see and which email client you use. If you encounter massive styling issues, you can always view the issue online.

Styling HTML emails is such a pain... My biggest pain points:

Anyways: I'm still available for freelance projects, contact me if you want to work with me.

Have a nice week ☀️


Vue Tip: Typing Component Events

Watch on YouTube

To declare emits with full type inference support, we can use the defineEmits API, which is automatically available inside <script setup>:

<script setup>
const emit = defineEmits(['change', 'delete'])
</script>

defineEmits is a compiler macro only usable inside <script setup>. It does not need to be imported and is compiled away when <script setup> is processed. defineEmits provide proper type inference based on the options passed.

Using TypeScript, it is also possible to declare props and emits using pure type annotations:

<script setup>
const emit = defineEmits<{
(e: 'change', id: number): void
(e: 'delete', value: string): void
}>()
</script>

defineEmits can only use either runtime declaration OR type declaration. Using both at the same time will result in a compile error.

Warning

Currently, complex types and type imports from other files are not supported.

The type declaration argument must be one of the following to ensure correct static analysis:

  • A type literal
  • A reference to an interface or a type literal in the same file

Curated Vue Content

📕 Vue skills to master in 2023

👉🏻 This article serves as your guide to the hot topics, tools and trends that you can stay on top of to elevate your code and level up your life.

www.vuemastery.com
📕 What is changing for Vuejs developers in 2023

👉🏻 Vite, VueUse, Pinia, TypeScript for Vue.js, the Composition API, Vitest, Nuxt 3!

vueschool.io
📕 Improving Reactivity with VueUse

👉🏻 Charles explores some of the VueUse utilities to help us improve reactivity in our Vue 3 application.

vueschool.io
📕 Nuxt 3 Migration Simplified: A Cheat Sheet
👉🏻 Upgrading to Nuxt 3 from Nuxt 2 can be a little intimidating.
👉🏻 Harlan wrote this cheat sheet to simplify the upgrade process for himself and "for others who are brave enough to tackle it".
harlanzw.com
📕 Build a streaming platform

👉🏻 In this tutorial, you learn how to build a live streaming application with with Vue.js and Go that displays the online status of users you are interested in and who are currently streaming a video.

pusher.com

Quote of the week

Quote of the week

JavaScript Tip: Replace Switch Statements With Object Literals

Watch on YouTube

I'm not a big fan of JavaScript's switch statement. Its syntax is hard to remember and can cause tricky bugs if you forget to add a break statement for every case.

Let's take a look at an example:

const getRole = (id) => {
switch (id) {
case 11:
return 'ADMIN'
case 22:
return 'OPERATOR'
default:
return 'USER'
}
}

I prefer using JavaScript's object literals over switch statements as the code is faster, more readable, and less verbose.

For each case we would have in the switch statement, we need to define an object key for each case:

const getRole = (id) => {
const rolesMap = {
11: 'ADMIN',
22: 'OPERATOR',
33: 'USER',
}
return rolesMap[id]
}

Finally, let's handle the default case of the switch statement by adding a default key:

const getRole = (id) => {
const defaultKey = 33
const rolesMap = {
11: 'ADMIN',
22: 'OPERATOR',
33: 'USER',
}
return rolesMap[id] ?? rolesMap[defaultKey]
}

We try to access the value using rolesMap[id] and use the nullish coalescing operator (??) to set the default value if the value is undefined or null.

Curated Web Development Content

📕 JavaScript Frameworks - Heading into 2023

👉🏻 Ryan Carniato ponders where JS frameworks are headed in 2023.

dev.to
📕 Notable improvements to Web Components in 2022

👉🏻 Serhii Kulykov wrote a review of the notable improvements to Web Components in 2022.

webcomponents.today
📕 Awesome ChatGPT
👉🏻 This repository contains a curated list of resources for ChatGPT and GPT-3.
👉🏻 It includes general resources, API tools, Chrome extensions, CLI tools, and more.
github.com
📕 Patterns.dev
👉🏻 A free book you can download in PDF format or enjoy on the web.
👉🏻 Learn about lots of fundamentals, from how different styles of rendering or importing resources work to performance optimizations and case studies.
www.patterns.dev
🛠️ Pirate Weather

👉🏻 A free and open weather forecast API that was built as a compatible alternative to the Dark Sky API.

pirateweather.net
Weekly Vue News LogoWeekly newsletter that gives you high-quality tips and curated content about Vue & Nuxt.
I will never share any of your personal data.
© 2023 weekly-vue.news. All rights reserved.