Open rinoldsimon opened 3 years ago
According to https://github.com/mansona/ember-cli-notifications/issues/257#issuecomment-823407763 the docs https://ember-cli-notifications.netlify.app/ needs to be updated ?
The docs reflect the expected service name by now 👍
I know that using @service notifications;
in a class works just fine. I'm less familiar with the manual inject
ion done via initializer, but I'm pretty sure there are at least 2 problems here:
The docs site gives an example of injecting with the injectionName
of notification-messages:service
, which looks like a typo to me. Run as written on a minimal Ember 3.28.x app results in the error in the OP:
Uncaught Error: Assertion Failed: Attempting to inject an unknown injection: 'notifications:service' at assert (index.js:178:1) at Registry.proto.validateInjections (index.js:1094:1) at processInjections (index.js:380:1) at buildInjections (index.js:407:1) at injectionsFor (index.js:422:1) at FactoryManager.create (index.js:510:1) at Proxy.create (index.js:250:1) at instantiateFactory (index.js:351:1) at lookup (index.js:279:1) at Container.lookup (index.js:144:1)
It should be service:notifications
like this:
Typo aside, the docs should not suggest using implicit injection since it is no longer recommended and doesn't even work in ember v4.x.
DEPRECATION: As of Ember 4.0.0, owner.inject no longer injects values into resolved instances, and calling the method has been deprecated. Since this method no longer does anything, it is fully safe to remove this injection. As an alternative to this API, you can refactor to explicitly inject
notifications
onroute
, or look it up directly using thegetOwner
API. [deprecation id: remove-owner-inject] See https://deprecations.emberjs.com/v4.x#toc_implicit-injections for more details.
See also:
Error: Assertion Failed: Attempting to inject an unknown injection: 'service:notification-messages'
Code: initializer/inject-notifications.js
Ember - 3.26.1 "ember-cli-notifications": "^6.3.4",