I had an issue handling many services
and solved it before finish this thread, but I’ll share it anyways
I have a heavy Page where I offer my main service,
so I decoupled it and now I have with six providers for it.
One of my services weren’t resolving all its parameters,
and I wen’t crazy trying to figure out what was the cause.
Basically I have:
|- EventsService (event bus)
|- SysService (local notifications)
|- SocketService (socket.io)
|- DataService (main data provider)
|- MainService (main coordinator)
I have a thin Page now moving away mostly of the code to the services and I feel I’m able to maintain everything easily.
Basically all of them depends on the Event Bus which communicates them, and the MainService takes the DataService too to perform some business logic changes, and finally the Page takes the Event, Data and Main Services.
I had the problem on the MainService not being able to resolve the DataService, and I had to go deep into
Reflect.js to see where the things went wild. Finally, now I’m aware that the declaration order in which Angular 2 loads the
@Injectables is important.
I’m using a Barrel, and there the DataService was exported AFTER the MainService, that was the LESSON of the day. I’ll be aware to put the dependencies before on my barrels now
I hope that this will be useful for someone one day