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
<!-- MouseTracker.vue --> | |
<script setup> | |
import { ref, onMounted, onUnmounted } from 'vue' | |
const x = ref(0) | |
const y = ref(0) | |
const update = e => { | |
x.value = e.pageX | |
y.value = e.pageY |
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
<template> | |
<slot :checkbox="checkbox" :toggleCheckbox="toggleCheckbox"></slot> | |
</template> | |
<script setup> | |
import { ref, reactive } from "vue"; | |
const API_ENDPOINT_URL = "https://official-joke-api.appspot.com/random_joke"; | |
const data = reactive({ |
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
<!-- Composable again --> | |
import { ref, onMounted } from "vue"; | |
export default function useDogImages() { | |
const dogs = ref([]); | |
onMounted(async () => { | |
const response = await fetch( | |
"https://dog.ceo/api/breed/labrador/images/random/6" | |
); |
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
<!-- DataProvider.vue --> | |
<template> | |
<slot | |
:data="data" | |
:loading="loading" | |
:error="error" | |
> | |
<component | |
:is="layouts[variant]" | |
:data="data" |
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
:D Jo, přesně tak! To jste trefil naprosto přesně. | |
V praxi to často vypadá takhle: | |
"Super-Mega-Awesome-Provider-Container-Renderless-Composition-Pattern™️" | |
```vue | |
<template> | |
<slot v-bind="data"> | |
<default-view v-bind="data" /> | |
</slot> |
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
<template> | |
<div> | |
<p>{{ props.state.label }}</p> | |
<button @click="props.actions.click">CLICK</button> | |
</div> | |
</template> |
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
// DataGrid.vue | |
<script setup> | |
const props = defineProps({ | |
items: { | |
type: Array, | |
required: true | |
}, | |
// Render funkce pro transformaci dat nebo komplexní logiku | |
cellRenderer: { | |
type: Function, |
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://javascript.plainenglish.io/memory-magic-in-javascript-why-weakmaps-and-weaksets-are-your-secret-weapon-for-high-performance-62562cc24dc5 | |
// 1. Private Data Storage Inside Classes | |
const privateData = new WeakMap(); | |
class BankAccount { | |
constructor(balance) { | |
privateData.set(this, { balance }); | |
} |
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://cdruc.com/form-composable | |
const router = useRouter(); | |
const form = ref({ | |
title: "", | |
content: "", | |
}); | |
const isProcessing = ref(false); |
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
const employees = [ | |
{ | |
id: 1, | |
first_name: 'Jan', | |
lastname: 'Novák', | |
age: 45, | |
salary: 85000, | |
role: 'CEO', | |
}, | |
{ |