O'Reilly logo

Mastering TypeScript by Nathan Rozentals

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dependency Resolution

Thus far, we have refactored our code to be dependent on an interface instead of a concrete object. This is all well and good, but begs the question: "how do we get hold of an interface?" – or more correctly – "how do we get hold of the concrete class that is currently implementing this interface?". This is the essential question that Dependency Injectors seek to answer.

There are a number of different ways in which a class can get hold of another class that implements an interface.

Service Location

If the class itself requests a concrete object based on an interface, then this process is called "Service Location". In other words, the class is using a registry or helper to locate the service it requires. You could also describe ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required