This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://www.vuemastery.com/courses/component-design-patterns/one-object-to-rule-them-all --> | |
<!-- To heavy , to complicated, all props we dont need ...--> | |
<template> | |
<main> | |
<Component | |
v-for="content in apiResponse" | |
:key="content.id" | |
:is="content.type" | |
:article-title="content.title" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
// 1 moznost, zapnout globalne | |
:root { | |
interpolate-size: allow-keywords; | |
} */ | |
.x { | |
width: 50px; | |
overflow: hidden; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
@url https://levelup.gitconnected.com/7-simple-async-await-tricks-for-developers-who-hate-asynchronous-javascript-fe370ac7fe72 | |
*/ | |
// 1. Use Promise.allSettled() for Safer Batch Processing | |
const results = await Promise.allSettled([ | |
fetchData1(), | |
fetchData2(), | |
fetchData3(), | |
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup> | |
import { shallowRef, watchEffect, triggerRef } from 'vue' | |
const user = shallowRef({ | |
name: 'John', | |
job: 'BFU', | |
age: 90 | |
}) | |
// Log the user whenever it changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo() | |
{ | |
const {promise, resolve, reject} = Promise.withResolvers() | |
setTimeout(() => { | |
resolve('DONE') | |
}, 2000) | |
return promise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Record<Keys, Type> | |
Keys může být string, number, symbol nebo union těchto typů. | |
Type může být jakýkoli typ. | |
Kdy Record využít | |
Když chcete zajistit, aby objekt měl přesnou strukturu s předem definovanými typy klíčů a hodnot. | |
Pokud například potřebujete typově bezpečně definovat mapování mezi hodnotami (např. slovníky nebo konfigurace). | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Pick: | |
Pick<T, K> je utility typ v TypeScriptu, který vytváří nový typ výběrem určitých vlastností K z typu T. | |
Používá se pro vytvoření podmnožiny existujícího typu. | |
*/ | |
// 1 | |
interface User { | |
id: number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// union | |
type StringOrNumber = string | number; | |
// intersection | |
type User = { id: number }; | |
type Admin = { isAdmin: boolean }; | |
type AdminUser = User & Admin; // { id: number; isAdmin: boolean; } | |
// return type | |
type GetUserType = () => { id: number; name: string }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Required je utility typ v TypeScriptu, který změní všechny vlastnosti daného typu na povinné (required). | |
*/ | |
interface User1 { | |
id: number; | |
name?: string; | |
email?: string; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Readonly je utility typ v TypeScriptu, | |
který změní všechny vlastnosti daného typu na pouze pro čtení (readonly) | |
Readonly<T> | |
*/ | |
// 1 | |
interface User { | |
id: number; |