Alex Lukinov
Alex Lukinov

Reputation: 785

Better way of using services in Angular

I have an DatesService which responsible for manipulate dates. Also I have two services who need to use date manipulation - EventsService and CalendarService. CalendarService use EventsService.

My question is: what is better (performance and everything else) - include DatesService in both services, or in CalendarService call DatesService through EventsService in this way: this.eventsService.datesService?

Upvotes: 0

Views: 40

Answers (1)

Tim
Tim

Reputation: 4274

We faced a similar "problem" and we decided to create a central provider service that contains many other services that are frequently used.

It does not make a difference performance-wise, but it is more convenient to inject only one service instead of several. It keeps the code clean and refactoring is easier.

Upvotes: 1

Related Questions