Vue JS 3: Composition API vs Options API - Same App in Both!

Поделиться
HTML-код
  • Опубликовано: 21 ноя 2024

Комментарии • 145

  • @MakeAppswithDanny
    @MakeAppswithDanny  3 года назад +1

    Please Like, Share, Subscribe & Comment - it all helps me create more content! for you!
    👉 My Courses: dannys.link/courses
    👉 Download Fudget: www.fudget.com
    👉 My VSCode Setup: dannys.link/vscodesetup
    👉 DONT CLICK THIS: dannys.link/dontclick

    • @BenHayat
      @BenHayat 3 года назад +1

      >> DONT CLICK THIS: dannys.link/dontclick
      Ok, I didn't... LOL

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад

      @@BenHayat 😂

  • @yogeshv6799
    @yogeshv6799 2 месяца назад +1

    Watching this in Sept 2024, and this series is really very helpful! Thank you so much!

  • @ericdelacruz2602
    @ericdelacruz2602 3 года назад +7

    One of the better explanations of the Composition API. It's really useful to see the comparison with the Options API.

  • @andrewking1173
    @andrewking1173 3 года назад +1

    I was so confused when some tutorials used the Options API and others used the Compositions API. This video was so helpful in showing that while they are syntactically different, they can do the exact same things. Thank You!!

  • @alexanderpoplawski577
    @alexanderpoplawski577 3 года назад +4

    Love your videos. They are fast paced and waste no time in endless speeches. I took your Quasar course on Udemy and can highly recommend it. Helped me a lot with a project where I had to make an Android app for a Zebra scanner and decided to use Quasar.

  •  3 года назад +1

    Whenever I find a Vue video from you I like before I watch because I know it will be gold. Thank you for helping me become a better developer.

  • @danuzonez
    @danuzonez Год назад +1

    Very nicely explained everything about options and composition api. ❤

  • @_ndiana
    @_ndiana 3 года назад +1

    Thank you for the video. Just to add that you could destructure `newTodoName` and `todos` from `data` while returning it from `setup()` so that you do not have to include `data` in the template. Well done.

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад +1

      Thanks, that's a good suggestion 👍

    • @_ndiana
      @_ndiana 3 года назад +1

      @@MakeAppswithDanny Caveat: Documentation says destructuring within setup() could break reactivity. I need to try this out and give a feedback.

  • @SAIEN333
    @SAIEN333 8 месяцев назад +1

    thank you for the tutorial , it was so easy to understand with both examples.

  • @CharlieKnoll
    @CharlieKnoll 3 года назад +1

    Very straightforward and entertaining! It seems Vue2 and knockout had a baby.

  • @maskman4821
    @maskman4821 2 года назад +2

    This is a awesome comparison about option-api and composition-api, thank you Danny ! 😀

  • @676005ga
    @676005ga 3 года назад +1

    Thanks for making this concise introduction of composition API, I finally understand what it is. I enjoy your Vuetify course and I hope to see this channel's growth, so you could create more content.

  • @flogginga_dead_horse4022
    @flogginga_dead_horse4022 3 года назад +1

    Very good comparison. I really prefer the original options way of doing things and spent a lot of time learning it!!

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад

      I was very resistant to the Composition API at first, but now I'm starting to get into it. I'm using it throughout Fudget 2.

  • @bryanthompson1070
    @bryanthompson1070 3 года назад +3

    Excellent tutorial sir! I appreciate the speed with which you present concepts while keeping it understandable with demonstration. Keep up the good work!

  • @zahid.messenger
    @zahid.messenger 2 года назад +1

    I think this is the video I was looking for. Reading documentation would not make this clear.

  • @Anaxarchos
    @Anaxarchos 3 года назад +1

    Great tutorial, easy to understand and concise.

  • @mikemcgrumpy
    @mikemcgrumpy 3 года назад +13

    You got a like from me because of how funny you found your own joke with the swear words.

  • @hongqiwang988
    @hongqiwang988 2 года назад +1

    Learned not only Vue but also some swear words from this tutorial. Thank you!

    • @MakeAppswithDanny
      @MakeAppswithDanny  2 года назад

      Haha! Just don't say them in front of your family...

  • @SusanthCom
    @SusanthCom 3 года назад +3

    Please come up with a course on utilising the power of TypeScript using vue 3

  • @truthteachers
    @truthteachers 2 года назад +1

    Hi Danny, at 21.12 timestamp, you said using the word "this" will not work from code in Options Api but it works. I copied the code as is and it worked fine. I guess things have since this date of this video.

    • @MakeAppswithDanny
      @MakeAppswithDanny  2 года назад

      Really? Can you please post the whole of your script section where you are using that (this.)?

    • @truthteachers
      @truthteachers 2 года назад

      @@MakeAppswithDanny Its hard to post it here. Its the same script you show in the video. Suggest you do the same course yourself and when you arrive at timestamp 21.02, do not remove the "this" word. Then test. It will not complain , it will work. Please use the latest vue/cli (mine is version 5) and vue js.

    • @truthteachers
      @truthteachers 2 года назад

      @@MakeAppswithDanny I have posted the same and the script in your latest video on the same subject.

  • @mostafashawki
    @mostafashawki 3 года назад +1

    Short and informative, that's why I am happy here :)
    keep it up! ✊

  • @jasonfetterly5578
    @jasonfetterly5578 3 года назад +1

    Very helpful video, thanks! You're a great speaker, good pace, thorough and accurate.. and got a little laugh in there too

  • @rejowanahmed6819
    @rejowanahmed6819 2 года назад +1

    Excellent video. Keep it up💖

  • @mikepecha8527
    @mikepecha8527 3 года назад +1

    Great channel! Keep up the great work Danny!

  • @SusanthCom
    @SusanthCom 3 года назад +1

    Clearly explained ❤️❤️❤️ thank you dear

  • @lucapassani1129
    @lucapassani1129 2 года назад +1

    Very nice video. I like the content/time ratio, the tempo. I am not planning to use the composition API but this is certainly useful to decode examples written that way by other programmers. I bookmarked this video for future reference. Thank you for taking the time to create it.
    What's the rationale for using composition over option API in your opinion? I am wondering why Vue authors felt the need to create an additional API that does the same things and can potentially be very confusing...

    • @MakeAppswithDanny
      @MakeAppswithDanny  2 года назад +1

      Thanks for the kind words Luca. All your concerns are explained in my Composition API Tutorial series: ruclips.net/p/PLAiDzIdBfy8jr-ccMU8ymPn7o85RAZ_6T

  • @raymondflowers1473
    @raymondflowers1473 2 года назад +1

    Composition API is most likely better than options so I think I might learn it first because of its ability to handle higher complexity according to what I've read online.

    • @MakeAppswithDanny
      @MakeAppswithDanny  2 года назад

      Yes, you don't necessarily need to learn Option API first. Check out my Vue 3 Composition API Tutorial Series: ruclips.net/p/PLAiDzIdBfy8jr-ccMU8ymPn7o85RAZ_6T

  • @lekhoi8
    @lekhoi8 3 года назад +1

    Excellent tutorial as always, why do we want to use ref() if the reactive data object will do. That is what is the use case for ref() ? Thanks

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад

      Well, if you only have one item of data within a particular bit of functionality, it might make sense to use a ref rather than an object.

  • @mrjiggawatt
    @mrjiggawatt 2 года назад +1

    I’m new to Vue and this is amazingly clear. However, I don’t really understand why you might choose the composition api over the option api or vice versa.

    • @MakeAppswithDanny
      @MakeAppswithDanny  2 года назад

      That's a deep question, but basically you have a lot more flexibility with the Composition API. Check out my Composition API series for further clarification on the benefits: ruclips.net/video/3B0ry4GI1cE/видео.html

  • @leonlee9518
    @leonlee9518 11 месяцев назад +1

    Thanks a lot , that's a great video!

  • @jamesconant6567
    @jamesconant6567 2 года назад +1

    Incredible

  • @aswinpreman907
    @aswinpreman907 2 года назад +1

    Great video bro.thanks a lot

  • @franckrichard9812
    @franckrichard9812 3 года назад +1

    Hi Danny thanks your work help me a lot (from Paris)

  • @nafisnawalnahiyan5032
    @nafisnawalnahiyan5032 9 месяцев назад +1

    Simple but awesome

  • @curtisschleich
    @curtisschleich 3 года назад +1

    Awesome as usual, Danny! Thanks!

  • @pankajarora2500
    @pankajarora2500 3 года назад +1

    Willy made my day :D

  • @tomzorz88
    @tomzorz88 2 года назад +1

    Great one!

  • @muhammad7238
    @muhammad7238 3 года назад +5

    love your laugh bro,I pray you keep laughing and smiling like this.

  • @zombaju
    @zombaju 3 года назад +2

    I don't know what the difference is between ref and reactive. It seems to me that reactive is a good idea when you have more stuff and want to keep it in one place. But there is one subject: in the images, i.e. , there is an attribute ref and to it you have to assign a value from ref, not from reactive because there will be an error. I noticed this while working with Tensorflow, when I wanted to use object detection from an image. I don't know why this happens. Therefore in . Magic.

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад +2

      Yes, refs that you assign to dom elements (to do something with the dom) need to be refs. But aside from these, refs are for simple variables, maybe string, or boolean and reactive are for objects. So if you had form data for a number of fields, you would probably put this in a reactive object. But if you had a standalone boolean variable, you would probably use a ref.

  • @bertrodgers2420
    @bertrodgers2420 3 года назад +1

    What colour scheme is that sir? Thanks for the helpful vid

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад

      Thanks Bert! It's the Make Apps Theme: marketplace.visualstudio.com/items?itemName=dannyconnell.make-apps-theme

  • @ferransanchez7422
    @ferransanchez7422 3 года назад +1

    Made my day! Thanks a lot

  • @dekebaoe
    @dekebaoe 3 года назад +1

    Great GREAT great!
    Thanks Danny

  • @bloomtech1085
    @bloomtech1085 3 года назад +1

    Hi Danny, do you create Quasar apps in Typescript? What do you think to develop with Typescript too? Thank you

  • @k.santiagodiaz3744
    @k.santiagodiaz3744 3 года назад +1

    Awesome! Is there any advantage on using ref or reactive over the other? idk, but ref seems more fancy to me...

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад +1

      I'm not sure to be honest, though reactive is a bit less fiddly as we don't need to use .value. Whether there is any performance difference between the two, I'm not sure.

  • @katteos
    @katteos 2 года назад +1

    Hey Danny, hope you are doing great. Nice explanation as always. Can you upload this to a github repo? Thank you

  • @vishny84
    @vishny84 2 года назад +1

    great example with swear words, I had a lot of fun ))) Thank you!

  • @BenHayat
    @BenHayat 3 года назад +1

    So Danny, what is the benefit of going with composition API? The option API structure seems more organized. Why should we switch?

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад +2

      Good question. It’s something I’m still trying to figure out. Supposedly it’s for large scale applications where you have components with multiple functionalities. Composition API would allow you to keep all of the data, computed properties, methods from each functionality together (instead of scattered across the various objects in the options API). But what I don’t get is- if your app and components are that complicated, then you should probably be using some kind of global state management anyway - in which case most of the data and logic would be moved out of the components. However one obvious benefit that springs to mind, is that you don’t need to make all of your data reactive. As I showed with the swearwords array - in the Options API example - this array was reactive - when it didn’t actually need to be. I imagine there is a performance cost to this. Whereas in the Composition API example, we didn’t need to make this array reactive.

    • @BenHayat
      @BenHayat 3 года назад +1

      @@MakeAppswithDanny
      Great answer and logic.
      Can't wait to see your video on using Composition API than Veux.
      BTW, based on your suggestion, I went ahead and decided my app's data will be manged by Vuex, and the actions will call methods in ApiServices layer which does all the Axios calls. This way Vuex does not do any direct Axios calls. Plus I can reuse the methods in ApiServices.

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад

      @@BenHayat sounds sensible. The “VueJS 3: Composition API for State Management (Vuex Killer?)” video will be out on Wednesday. 👍

  • @rangabharath4253
    @rangabharath4253 3 года назад +2

    Love your laugh 😂😂😂. Awesome 🤣🤣

  • @dwarslopers
    @dwarslopers 2 года назад +1

    Thanks! I love that humor. Buy bananas, Eat bananas, Poo bananas!🤣

  • @pagevpetty
    @pagevpetty 3 года назад +1

    so, we can just start using the syntax without installing it?

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад +1

      Sure, if it's a Vue 3 project. If it's a Vue 2 project, you need to install the composition API polyfill 👍

  • @michaelpumo83
    @michaelpumo83 3 года назад +1

    Any reason you used a computed property just to return the length of the array?

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад

      This was explained in the video. I just did this so that I could demonstrate how computed properties differ in Options API & Composition API - not because it was necessary.

  • @rangabharath4253
    @rangabharath4253 3 года назад +1

    awesome as always :-)

  • @erhanturan
    @erhanturan 3 года назад +1

    hilariously informative! nice :)

  • @pedroprt007
    @pedroprt007 2 года назад +4

    Excellent tutorial as always.
    I can't see a reason to move from options api to composition api. I think composition api is just a more complicated way of doing the same thing we do easily with options api.

    • @MakeAppswithDanny
      @MakeAppswithDanny  2 года назад +1

      I used to think so too. Keep an eye out for my forthcoming course "Vue 3: Composition API (with Pinia & Vite)" and my forthcoming RUclips series "Vue 3 Composition API Tutorial Series" and a few other videos I have coming. They might just change your mind a bit 👍

    • @mikey7673
      @mikey7673 2 года назад

      Vue 2 out of support end 2023 :)

    • @rejowanahmed6819
      @rejowanahmed6819 2 года назад

      Composition API is more Javascript Approach than Options API and it's obviously easier to follow and code. I think you should rethink that

  • @dimitry5479
    @dimitry5479 3 года назад +1

    Cool! Especially - butt hair.

  • @GergelyCsermely
    @GergelyCsermely 3 года назад +1

    :) thanks

  • @MauroSSosa
    @MauroSSosa 11 месяцев назад +1

    How can I maintain the structure using asyncComputed by vue-async-computed lib in vue3 with OptionsApi?
    asyncComputed: {
    items: {
    async get() {
    return await fetch(...);
    },
    default: [],
    },

    • @MakeAppswithDanny
      @MakeAppswithDanny  10 месяцев назад

      I'm not sure about that Mauro. Best of luck 👍

  • @eliranmauda
    @eliranmauda 3 года назад +3

    I understand the composition API, I don;t TRULY understand where or why should I be using it... I feel like a willy..........

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад

      Now that I'm used to it, I use it exclusively. In Fudget 2, I haven't used the Options API at all. This explanation might help: ruclips.net/video/_wAW8_9h2FQ/видео.html

  • @HowardBuksbaum
    @HowardBuksbaum 3 года назад +3

    Thumbs up for the laughing alone

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад

      😂

    • @HowardBuksbaum
      @HowardBuksbaum 3 года назад +1

      @@MakeAppswithDanny Love your videos dude! Hey can you do a video on centering a grid in Quasar where the last row of items is left aligned?

    • @MakeAppswithDanny
      @MakeAppswithDanny  3 года назад

      @@HowardBuksbaum hey Howard. I replied to your tweet. Won’t it be neater to have all rows left aligned? Otherwise the last row with one item won’t be aligned with the cantered rows above.

    • @alexanderpoplawski577
      @alexanderpoplawski577 3 года назад +1

      I laughed before he did. Reminded me of kindergarten kids, exchanging their dirtiest swear words.

  • @EduardoDonato82
    @EduardoDonato82 3 года назад +1

    Who is Willy?

  • @gotechkey1185
    @gotechkey1185 2 года назад +1

    Am I the only one wondering why you were laughing? LOL

  • @antoniofuller2331
    @antoniofuller2331 2 года назад +1

    Hmm

  • @rickybarabba7866
    @rickybarabba7866 3 года назад +1

    Give me a shout when... ;-)

  • @FitLife6767
    @FitLife6767 3 года назад +1

    I didn't know 'fart' was a swear word.

  • @flogginga_dead_horse4022
    @flogginga_dead_horse4022 3 года назад +1

    so childish lol great stuff!!

  • @pagevpetty
    @pagevpetty 3 года назад +1

    Stop those bad people! 😹

  • @ontwikkelfabriek
    @ontwikkelfabriek 3 года назад

    no source?

  • @piuschris
    @piuschris 9 месяцев назад +1

    🤣🤣🤣🤣

  • @ontwikkelfabriek
    @ontwikkelfabriek 3 года назад

    btw your Fudget site is not https