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:

Rxjs Adoption Guide: Overview, Examples, And Alternatives

RxJS adoption guide: Overview, examples, and alternatives

Get to know RxJS features, benefits, and more to help you understand what it is, how it works, and why you should use it.

Emmanuel Odioko
Jul 26, 2024 â‹… 13 min read
Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 â‹… 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 â‹… 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 2024 â‹… 5 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