Vue Dependency Injection Simplified

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • Dependency injection using the provide/inject pattern is a great way to make your app more readable and easy to maintain.
    ✅ FREE VUE 3 CHEATSHEET WITH ESSENTIAL CODE SNIPPETS
    learnvue.co/vu...
    follow me on twitter:
    / mattmaribojoc
    🚨 Like quick Vue lessons like these? Check out 800+ lessons over on Vue School - go.learnvue.co...
    Music by Lukrembo

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

  • @ReDestro69
    @ReDestro69 2 года назад +5

    Started following your channel some weeks ago and I don't regret it. Your videos aren't very lengthy but always precise and straight to the point. 👍🏽

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

      appreciate it! you’re the best for this comment 💚

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

    Rewatching this due to being jammed up with a user merged with defaults library config data -> prop validator data currently using provide/inject pattern.
    Really appreciated the chill bg music this time around @LearnVue :) Cheers and happy coding!

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

    Love this short format! Every time RUclips suggests your video, I am like: "Cool topic, I should add this video to Watch Later... Oh, it's only 3 minutes long, better watch now". Therefore I have a ton of videos in my Watch Later list, but yours only in History 😋

  • @cindrmon
    @cindrmon 7 месяцев назад

    istg today i found out about this when i needed it the least.. i still appreciate it

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

    It’s a mix feeling using provide and inject, it is definitely handy in nested structure, however if you want to constrain the exactly what the component needs and make it clean and slim, I slowly back to the habit to use props way.

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

    👏🏼👏🏼👏🏼 always wondered what I was doing wrong with passing data to child components, this helps a ton!

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

    How did i not know this before, this is amazing. Thank you

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

    Great video! Appreciate that you showed how to do it with

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

      Of course! is pretty handy (once you understand the original setup syntax)!

  • @jaqb_007
    @jaqb_007 Год назад

    Great description, thanks

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

    Readonly capabilities from Vue 🔥 🔥

  • @jakubzomerfeld2159
    @jakubzomerfeld2159 2 года назад +9

    As always great but the music volume level is to high, about 1/3 too loud :) overall thank You for amazing new tip :)

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

      Sorry about that! Thanks for the feedback and I'll keep an eye on that for future vids 😀

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

      Music’s just right on my end. No change necessary. ;)

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

      I‘d say 10% less would be perfect :D

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

    I’m pretty sure you’re aware of this, that the Composition API also provides an alternative for this kind of situations through state management, which is really useful and works just as well as Vuex (for small projects at least). It would be really interesting to watch your take on this :) Thank you!

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

      @dnvdk I have that one pending :)

    • @LearnVue
      @LearnVue  2 года назад +5

      i've also been looking at PINIA, would you all be interested in a quick video?

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

      @@LearnVue more than interested! :)

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

    Nise!!! I really like this feature.. thanks for showing it.

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

      you're welcome! glad you like it

  • @khaldounal-nuaimi3594
    @khaldounal-nuaimi3594 2 года назад

    Thank you so much for this! Helped me a lot!

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

      glad it helped!!

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

    Can you please make a tutorial on how to watch for changes in the provided data. E.g. Watching for a change in a variable that resides in the drawer component?

  • @1boompje
    @1boompje 2 года назад

    Thanks!

  • @aravindmuthu5748
    @aravindmuthu5748 Год назад

    useContext for vue

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

    Isnt it better to export a reactive const and import it where needed? Whats the benefits to use this way?

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

      Export a reactive const would be a way to mimic a store like state where any component (regardless of hierarchy) could access the data. Provide/inject works more like props where the components that need access to this data have a parent/child relationship.
      While I think having some sort of application state has many purposes (Vuex), in strictly parent/child components, it can make your data better represent your component structure and reduce the possible number of places where your data can be mutated.

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

    amazing, thanks!

  • @augischadiegils.5109
    @augischadiegils.5109 2 года назад

    ♥️♥️♥️

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

    What if our child component is very deep in tree so when we provide reactive data to child does it will re-render all the components in between child and parent component?

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

    Why don't you just use Pinia?

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

      that's also possible, this is what pinia does behind the scenes!

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

    Why does it feels like a state management/Vuex all over again.

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

      because it is! this is a more minimal way to implement state management across components without adding a full library.

  • @TodorescuProgramming
    @TodorescuProgramming Год назад

    the background music is disgusting