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.

@Inject() doesn't work and why should i use Container.get()

See original GitHub issue

why should i use Container.get() Am I using typedi wrong way?

t.ts

export class T {
	@Inject("userService") private userService!:UserService;

         constructor(){}
}

service.ts

@Service("userService")
export class UserServiceImpl implements UserService{
}

run.ts

export default function index(){
 
    const passport =new T();
    // const passport = Container.get(Passport);  why should i use Container.get()
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
justinmchasecommented, Jul 24, 2019

Yeah I think it doesn’t need to be flagged as a service technically. It will just use the Type as the identifier for a class in the simple case.

class Model {
  constructor(private logger: Logger) { }
}

const model = Container.get(Model)
0reactions
github-actions[bot]commented, Aug 31, 2020

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeDI @Inject() doesn't work, but Container.get() does
You need to create your instance of SomeClass using Container#get , or the container won't be able to inject the property.
Read more >
Dependency injection and inversion of control in Python
When you call the main() function the Service dependency is assembled and injected automatically. When you do testing, you call the container.api_client.
Read more >
Introduction to Contexts and Dependency Injection - Quarkus
This is a scope annotation. It tells the container which context to associate the bean instance with. In this particular case, a single...
Read more >
InversifyJS a powerful IoC container for JavaScript apps ...
A IoC container uses a class constructor to identify and inject its dependencies. InversifyJS has a friendly API and encourage the usage of...
Read more >
PHP definitions
$containerBuilder->addDefinitions([ // place your definitions here ]); ... Do not use new (e.g. new DI\create() ) or you will get a fatal error...
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