Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify the method of using provider #255

Open
ockan opened this issue Dec 6, 2024 · 1 comment
Open

simplify the method of using provider #255

ockan opened this issue Dec 6, 2024 · 1 comment

Comments

@ockan
Copy link

ockan commented Dec 6, 2024

Now,to realize the provider,3 steps needed:

1\declare the injectable service:
image

2\give it as a argument of AppFactory:
image

3\use really the provider:
image

that is complex.why need to use the decorator '@Injectable'? why need to register provider to AppFactory?it is confused.

@eadwinCode
Copy link
Collaborator

@ockan @Injectable is used to define the lifetime scope of the provider object.
If you don't use @Injectable, and you register the service on the AppFactory or Module the application will assume the provider as a singleton scope.
Also, providers in AppFactory or `Module' are registered in the Ellar DI container making them available for injection.

But @ockan, if you feel there are other ways this could be made easy, please share, I would love to hear your suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants