Build your own Custom Composables in Vue

  Рет қаралды 44,634

Vue Mastery

Vue Mastery

Күн бұрын

Пікірлер: 45
@VueMastery
@VueMastery Жыл бұрын
Watch the full Coding Better Composables course here: www.vuemastery.com/courses/coding-better-composables/what-is-a-composable
@Andrey-il8rh
@Andrey-il8rh 2 жыл бұрын
Very important topic, looking to see more content on that. Looking on how people use composition api in big enterprise projects I see a lot of issues with understanding the fundamentals which causes a lot of problems such as: - Tight coupling of composables between each other: people try to call a composable inside composable which doesn't allow proper tree shaking - Placing to much stuff inside a composable - many times people just detach all domain logic from components, creating one mega composable that just floats in space similar to Vuex store which causes memory leaks and makes overall application more complex to understand - Trying to use reactivity for everything - for some reason people just thinking that reactivity is free of charge and converts objects with tenths of thousands properties received from a server straight into reactive function, which leads to huge issues with performance. Summarizing all of the above I think it would be great to talk about how to "not write composables" or a list of do's and don'ts
@eddieaguilar4878
@eddieaguilar4878 2 жыл бұрын
Where can i find this content. It is gonna be very useful to read about it
@Andrey-il8rh
@Andrey-il8rh 2 жыл бұрын
@@eddieaguilar4878 what content? It was a suggestion/request to Vue Mastery, not something already available int the internet for you to watch
@VueMastery
@VueMastery 2 жыл бұрын
Hello! You can find a written tutorial series on Composables in our blog here: www.vuemastery.com/blog/coding-better-composables-1-of-5 I just linked you to Part 1, but Parts 2-5 are also available there. 😁
@illmatic7005
@illmatic7005 2 жыл бұрын
One thing to avoid would be using "options" as a param for the composition APIs that you build. This forces the user dev of the API to have to go read the code to figure out what the options are, and in the case of your third example would force them to go down a rabbit hole of reading API implementations that the API they are trying to call is using. For writing APIs in any language / framework it's best to expose what all possible args are and in JS can be done by: function myFunc({arg1, arg2}) {...} This allows the caller of myFunc to quickly see what the param options are and pass them along in a single object, most IDEs will show this as a hint when using the function, so you won't even have to go and find where the API is defined.
@Peter-bg1ku
@Peter-bg1ku 2 жыл бұрын
You can add doc blocks to the function with type definitions.
@felixbecquart
@felixbecquart 2 жыл бұрын
Love your videos. Sooo pedagogic
@avimehenwal
@avimehenwal 2 жыл бұрын
Wow!! going through such a advanced topic looks like a breeze with amazing instructors :D Again thankyou for such super high quality video (Y) C Cheers
@fourthkim3715
@fourthkim3715 2 жыл бұрын
I wanna ask on 4:09, isnt that way options is required? How to make it as optional?
@GOGODEV
@GOGODEV 2 жыл бұрын
Really nice video. Congrats!
@VELIXYZ
@VELIXYZ 2 жыл бұрын
Thank you! Very useful video, wish i can see it everyday
@LuckyTechy
@LuckyTechy 2 жыл бұрын
lol what. why can't you?
@gateitogototo8976
@gateitogototo8976 2 жыл бұрын
amazing but also mindblowing for me 😁
@024hadzia
@024hadzia 2 жыл бұрын
Very useful. Thanks! :) 💚
@Zaloganon
@Zaloganon 2 жыл бұрын
I have a question, are there any difference between This one: myValue ?? defaultValue and This one: myValue || defaultValue In both cases, it will return the firt truly value found, so, why does exists '??' operator in js?
@hhh0118
@hhh0118 2 жыл бұрын
"myValue ?? defaultValue" returns the first value that is not explicitly null or undefined, meaning it will return the first defined value, including an empty string, 0, true or false. Let's say you want the "defaultValue" set to the boolean "true", but you want to be able to pass the boolean "false" as "myValue". Using "myValue ?? defaultValue" will work as intended in that case because "myValue" isn't null or undefined, while "myValue || defaultValue" would always ignore the boolean "false" being sent as "myValue". "myValue || defaultValue" returns the first truthy value, meaning it will skip e.g. undefined, null, false, 0 or empty string. You would only ever be able to pass truthy values as "myValue", or they would always be ignored and "defaultValue" would be used instead. undefined ?? null ?? false ?? true -> returns the boolean "false" undefined ?? null ?? 0 ?? true -> returns the number 0 undefined ?? null ?? "" ?? true -> returns an empty string undefined || null || false || 0 || "" || true -> returns the boolean "true" I might've repeated myself a bit, but I hope that cleared things up.
@Zaloganon
@Zaloganon 2 жыл бұрын
@@hhh0118 a lot of thanks for explanation! I didn't know that. Now I understand the difference :D
@kecoje
@kecoje 5 ай бұрын
Why not use typescript?
@hmatpin
@hmatpin Ай бұрын
I think the problem with Vue3 is that if they were just going to copy everything from react, which is the case with composables, they should have kept the original names as well, i.e. composables should be called React custom hooks.
@azizsafudin
@azizsafudin 2 жыл бұрын
Isn’t that just a hook?
@victoralcala
@victoralcala 2 жыл бұрын
React name them hooks, Vue name them composables. Yes, same idea
@trunghieuhoang3839
@trunghieuhoang3839 2 жыл бұрын
Hooks with super power :)) It can be used out side components, don't need to useCallback, useMemo for optimizing rerender. Anw I love react thought
@killerdroid99
@killerdroid99 2 жыл бұрын
@@trunghieuhoang3839 I don't want to hear those *useFootGuns* atleast here
@Peter-bg1ku
@Peter-bg1ku 2 жыл бұрын
Yes, same thing. Very nice addition to Vue.
@xenos112
@xenos112 Жыл бұрын
​@@killerdroid99agree
@andogrando487
@andogrando487 11 ай бұрын
I've been seeing a lot of arguments lately that we should just be using typescript classes in favor of composables - just curious if anyone had some feelings about that.
@briankgarland
@briankgarland 2 жыл бұрын
So, basically, it's a utility function?
@dpv.school1236
@dpv.school1236 2 жыл бұрын
I didn't really understand anything you said because you were always explaining JS and TS syntax and only gave a couple of examples.
@Andrey-il8rh
@Andrey-il8rh 2 жыл бұрын
Maybe you need to learn JS and TS first before watching such videos?
@ZlatkoIliev-s4j
@ZlatkoIliev-s4j Жыл бұрын
Basically this is a React.js hooks! Why is everything in Vue copy-pasted from React mostly?!?
@xman6267
@xman6267 2 жыл бұрын
Svelte or vue?
@ftapia
@ftapia 2 жыл бұрын
Why ask in a Vue channel?
@dpv.school1236
@dpv.school1236 2 жыл бұрын
Svetle
@fasoolya
@fasoolya 2 жыл бұрын
Nuxt
@nimblefrogcreations
@nimblefrogcreations 10 ай бұрын
Video: How to build your own custom composable Also Video: Here's how you install and use our own pre-made composables
@isidorenwaiwu2793
@isidorenwaiwu2793 2 жыл бұрын
More more more
@VueMastery
@VueMastery 2 жыл бұрын
Have you seen our blog series? It's 5 parts and talks all about Composables: www.vuemastery.com/blog/coding-better-composables-1-of-5
@rallolollo9309
@rallolollo9309 2 жыл бұрын
rly sad that vue is going down the react way, it's a bad way confusing, much boilerplate for nothing i hope they keep the double way updated with all the new features otherwise bb vue and i will move to svelte for fast small projects and angular for big ones
@dpv.school1236
@dpv.school1236 2 жыл бұрын
I agree with you it's really boilerplate that allows developers write strange stupid logic instead of business logic and force to think about side effects. Global functions, events and states are always evil especially in junior hands
@Andrey-il8rh
@Andrey-il8rh 2 жыл бұрын
@@dpv.school1236 well, Vue 3 still supports options API so you can continue using that, composition API is clearly not for beginners, it's just a tool for a very specific use cases, similar to Vuex - you should not put all of your data inside of it. So if you allow yourself to learn with open mind and a grain of common sense - Composition API won't become anything stupid
@AnassSanba-f5d
@AnassSanba-f5d Жыл бұрын
Bruh it's just a JavaScript function
@isidorenwaiwu2793
@isidorenwaiwu2793 2 жыл бұрын
More more more
Getting Started with Pinia | Crash Course
10:02
Vue Mastery
Рет қаралды 23 М.
Common Mistakes in Vue js and How to Avoid Them - Daniel Kelly
29:49
VueConf Toronto
Рет қаралды 11 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
Stop Using .value with ref In Vue 3! Reactivity Transformed Explained!
14:22
New component patterns for Vue 3
21:12
Vue Mastery
Рет қаралды 38 М.
Patterns for Large Scale Vue.js Applications - VueConf US 2023
18:54
Unit Testing Vue Apps: Tips, Tricks, and Best Practices
29:51
Vue Mastery
Рет қаралды 13 М.
Un-Suck Your React Components - Composable & Compound Components
15:47
Эволюция кода на Vue.js: дубли, mixins (примеси), composables
1:34:34
5 Patterns for Better Components in Vue.js - Michael Thiessen
29:08
VueConf Toronto
Рет қаралды 9 М.
7 Awesome TypeScript Types You Should Know
8:57
Josh tried coding
Рет қаралды 92 М.
Vue 3: Reactivity Made Easy (ref, reactive, toRefs... oh my!)
13:04
Program With Erik
Рет қаралды 50 М.
The Difference Between Vue and React
10:27
Lachlan Miller
Рет қаралды 44 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН