Suppose an app has 2 services:
foo wants to use
Suppose we want all services to be able to log and if in an initializer we did:
application.inject('service', 'log', 'service:log')
Ember throws: Error: Cannot inject a
service:log on other service(s).
But we can inject
log only on
application.inject('service:foo', 'log', 'service:log')
This brought up some questions:
From a design point of view what impact would it have to inject a service on another service? Is it better avoided?
Instead of a service, we can use a log
Then, import it:
import log from 'my-app/utils/log'
and invoke it:
log.error('An error occurred.')
Wouldn’t this also be a solution. (btw, in this case, will
logno longer be a singleton if imported in multiple files?)
Just trying to better understand this. Would be great if anyone could point out pros and cons. Thanks.