Skip to content

Move application-wide services from SharedModule to CoreModule #11

@ryzy

Description

@ryzy

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions