🌀
type-chef-di Docs
GitHub
  • 👋Welcome to type-chef-di documentation
  • Overview
    • ✨Getting started
  • Fundamentals
    • 🍎Container Options, extendability
    • 👨‍🍳Injection
      • 🍕Type injection
      • 🍪Token registration
      • ☕Token Injection
      • 🌮Mixed injection
    • 🛠️Decorators
      • ✅@Injectable({instantiation: "singleton" | "prototype"})
      • 🎯@Inject<T>(key: string | Type<T>)
      • 🍍@InjectProperty<T>(key: string | Type<T>)
      • 🍭@Setter()
      • 🔆@InitMethod()
      • 🏭@FactoryMethod()
      • ⚡@AddTags(tags)
      • 🪃@RunBefore(key: string | Type<IRunBefore>)
      • 🛴@RunAfter(key: string | Type<IRunAfter>)
      • 🌕@MethodWrapper(key: string | Type<IMethodWrapper>)
  • Use Cases
    • 🎨Plans
    • 🖥️For Developers
  • Other
    • 💡DI / IoC
Powered by GitBook
On this page
Edit on GitHub
  1. Other

DI / IoC

What is a DI / IoC?

PreviousFor Developers

Last updated 2 years ago

IoC

inversion of control (IoC) is a programming principle. IoC inverts the as compared to traditional control flow. In IoC, custom-written portions of a receive the flow of control from a generic . A with this design inverts control as compared to traditional : in traditional programming, the custom code that expresses the purpose of the program into reusable libraries to take care of generic tasks, but with inversion of control, it is the framework that calls into the custom, or task-specific, code.

dependency injection is a in which an or receives other objects or functions that it depends on. A form of , dependency injection aims to of constructing objects and using them, leading to programs. The pattern ensures that an object or function which wants to use a given should not have to know how to construct those services. Instead, the receiving '' (object or function) is provided with its dependencies by external code (an 'injector'), which it is not aware of. Dependency injection helps by making implicit dependencies explicit and helps solve the following problems:

  • How can a be independent from the creation of the objects it depends on?

  • How can an application, and the objects it uses support different configurations?

  • How can the behavior of a piece of code be changed without editing it directly?

💡
flow of control
computer program
framework
software architecture
procedural programming
calls
design pattern
object
function
inversion of control
separate the concerns
loosely
coupled
[1]
[2]
[3]
service
client
[4]
[5]
class