question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provided Named Dependencies

See original GitHub issue

How to use the provides method to replace named dependencies inside the dependency graph ?

e.g

provides(
                @Named("Auth") OkHttpClient::class.java, // throws compile time error
                MockHttpClient.getClient())

Is there any other way to do this ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
fabioCollinicommented, Mar 27, 2019
1reaction
fabioCollinicommented, Sep 4, 2018

Hi @krazykira, I have implemented this feature in the last commit 383fa8003e, can you try it using this commit as DaggerMock version?

In your example the syntax to use should be this:

 provides<OkHttpClient>("Auth", MockHttpClient.getClient())

Let me know if it works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Named injected dependencies in .NET 5 / Core - Realfiction
In some research I came across Steve Collins' blog post on "Getting named dependencies by Name or Key using the .NET Core Container"....
Read more >
Getting Dependencies by Name or Key using the .NET Core ...
In this post, I demonstrate how to use custom typed delegates to perform named/keyed dependency injection using the Microsoft Dependency ...
Read more >
c# - Dependency injection resolving by name - Stack Overflow
I found the quickest object instantiation occurred when I merely ran a simple LINQ query against the IEnumerable that's created by default in...
Read more >
Dependency injection in ASP.NET Core | Microsoft Learn
Services and their dependencies within an ASP.NET Core request are exposed through HttpContext.RequestServices. The framework creates a scope ...
Read more >
Dependency Injection using @Inject and @Named Annotations
The Dependency is Mandatory when using @Inject. If it is not available,it will throw an exception at run-time. You can use @Nullable annotation ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found