This file contains hidden or 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
| import { JSX, For } from 'solid-js' | |
| interface Props<T> { | |
| items: T[] | |
| children: T => JSX.Element | |
| } | |
| function GenericList<T> (props: Props<T>) { | |
| return ( | |
| <For each={ props.items }> |
This file contains hidden or 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 fn(num) { | |
| const validNumbers = [] | |
| sortedNumbers.some((n) => { | |
| const comp = n > num | |
| if (!comp) { | |
| validNumbers.push(n) | |
| } | |
| return comp | |
| }) | |
This file contains hidden or 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 class="container"> | |
| <img v-if="isOnScreen" width="25%" :src="src" @load="loaded"> | |
| </div> | |
| </template> | |
| <script> | |
| import { useOnScreen } from "../hooks/screen"; | |
| import { useLazyLoad } from "../hooks/lazyLoad"; |
This file contains hidden or 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
| import { onMounted, onUnmounted, ref } from "@vue/composition-api"; | |
| export function useOnScreen() { | |
| let isOnScreen = ref(false); | |
| const observer = new IntersectionObserver(entries => { | |
| isOnScreen.value = entries.some(entry => entry.intersectionRatio > 0); | |
| }); | |
| onMounted(function() { |
This file contains hidden or 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 observer = new PerformanceObserver(list => { | |
| list.getEntries().forEach((entry) => { | |
| //handle each performance mark | |
| }) | |
| }) | |
| observer.observe({ entryTypes: [ 'mark', 'measure'] }) |
This file contains hidden or 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
| Vue.config.performance = true |
This file contains hidden or 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 v-if="outOfView" class="placeholder"> </div> | |
| <div v-else> | |
| <slot></slot> | |
| </div> | |
| </template> |
This file contains hidden or 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
| export default { | |
| methods: { | |
| // better for readability | |
| async veryReadable() { | |
| const { data } = await axios.get(`https://jsonplaceholder.typicode.com/post/${response.data[0]}/comments?_page=1`) | |
| this.comments = data | |
| }, | |
| // better for returning a promise for chaining | |
| returningPromise() { |
This file contains hidden or 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 observer = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.intersectionRatio > 0) { | |
| observer.disconnect() | |
| this.showComments = true | |
| } | |
| }) | |
| }, this.options) | |
| observer.observe(this.$refs.ending) |
This file contains hidden or 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 v-if="outOfView" class="placeholder"> </div> | |
| <div v-else> | |
| <slot></slot> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| props: { |
NewerOlder