2021-07-19
970
#vue
Emmanuel John
58675
Jul 19, 2021 â‹… 3 min read

Dependency injection in Vue: Advantages and caveats

Emmanuel John I'm a full-stack software developer, mentor, and writer. I am an open source enthusiast. In my spare time, I enjoy watching sci-fi movies and cheering for Arsenal FC.

Recent posts:

Comparing Hattip Vs Express Js For Modern Application Development

Comparing Hattip vs. Express.js for modern app development

Explore what Hattip is, how it works, its benefits and key features, and the differences between Hattip and Express.js.

Antonello Zanini
May 2, 2024 â‹… 8 min read
Using React Shepherd To Build A Site Tour

Using React Shepherd to build a site tour

React Shepherd stands out as a site tour library due to its elegant UI and out-of-the-box, easy-to-use React Context implementation.

Onuorah Bonaventure
May 1, 2024 â‹… 14 min read
A Guide To Cookies In Next Js

A guide to cookies in Next.js

Cookies are crucial to web development. This article will explore how to handle cookies in your Next.js applications.

Georgey V B
Apr 30, 2024 â‹… 10 min read
Handling Dates In JavaScript With Tempo

Handling dates in JavaScript with Tempo

Use the Tempo library to format dates and times in JavaScript while accounting for time zones, daylight saying time, and date internationalization.

Amazing Enyichi Agu
Apr 30, 2024 â‹… 8 min read
View all posts

6 Replies to "Dependency injection in Vue: Advantages and caveats"

  1. Why would you need to inject dependencies when you have Vuex? The prop drilling example is easily mitigated with state management.

    1. While Vuex can mitigate prop drilling, it is worth noting that it can be an overkill and added complexity for small to medium Vuejs applications.

  2. With dependency injection, DurryComponent would receive the wallet from RexComponent without passing through TomComponent and PeterComponent.

    Actually no. The dependency will traverse the entire descendant tree and will be available to any nested components. That’s the main problem with vue di. You can’t control the di process.

    1. Hi Predi, actually that illustration was a quick comparison between dependency injection and prop drilling. With DI we don’t have to pass the values manually like we do with props. I will provide some updates for more clarity. Thanks!

Leave a Reply