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

Move application-wide services from SharedModule to CoreModule #11

Open
ryzy opened this issue Dec 23, 2016 · 0 comments
Open

Move application-wide services from SharedModule to CoreModule #11

ryzy opened this issue Dec 23, 2016 · 0 comments

Comments

@ryzy
Copy link
Owner

ryzy commented Dec 23, 2016

Application-wide services should be defined in the root application-wide injector. In our case, because all feature modules are loaded lazily, they create their own child injectors, where e.g. our GitHubAPIService is registered.

There's a real risk that we'll have more than one instance of that service, one in the root injector, one created by child injector. It's not a big deal in our case, but it's not a good practice (as described in the doc in Angular Modules chapter.

Instead, we should create the CoreModule, which is imported by AppModule (and only there) and move single-use classes there.

@ryzy ryzy changed the title Move application-wide services from SharedModule to root module Move application-wide services from SharedModule to CoreModule Dec 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant