Let's say we have the following:
A CoolModule
(cool.module.ts) which takes care of cool stuff.
The CoolModule
contains the following:
CoolDialogComponent
(cool-dialog.component.ts)CoolService
(cool.service.ts)- ...other cool files
An application that uses CoolModule
is using it's functions through the CoolService
, which is an injectable singleton service.
CoolService
has a bunch of cool methods. One of them can open a material-dialog. It passes the CoolDialogComponent
for the dialog to use it as the dialog's content.
The CoolDialogComponent
has a particular action that calls one of the CoolService
's methods.
At this point:
CoolDialogComponent
has a dependency onCoolService
CoolService
has a dependency onCoolDialogComponent
Am I the only one here who thinks that this shouldn't be refactored just because of the circular dependency warning?
- I think the
CoolService
does it's job to be an injectable service that we can use it's features through. - The
CoolDialogComponent
does it's job by defining the modal dialog's content. And it's able to call on of it's methods. - Both of them are bounded together in the
CoolModule
, they don't exist without each other. - Creating an additional service just to solve the circular dependency warning seems a bit like raping it's structure.
Please explain me the point that I don't see here! And/or provide a solution to get rid of the warning! (No I don't want to turn it off in angular-cli's config).