[Bug] String injection with `instantiate: false` no longer works on ember 3.27.0
See original GitHub issue🐞 Describe the Bug
Injecting a string via dependency injection raise an error.
🔬 Minimal Reproduction
Minimal reproduction on fresh app : https://github.com/romgere/test-ember-string-injection
- Currently on ember 3.26 : working
- Update to ember-source@3.27.0 : breaking
To sum-up Try to inject a string into a service with an initializer :
// initializer.js
export function initialize(application) {
application.register('config:a-string', 'My great injected string', {
instantiate: false,
});
application.inject(
'service:test-injection',
'injectedString',
'config:a-string'
);
}
export default {
initialize,
};
// service.js
import Service from '@ember/service';
export default class TestInjectionService extends Service {
injectedString = null; // injected by initializer
}
😕 Actual Behavior
When trying to use the service property got the following error :
Uncaught TypeError: Cannot create property 'Symbol(INIT_FACTORY)' on string 'My great injected string'
🤔 Expected Behavior
The property is setted with injected string.
🌍 Environment
- Ember: 3.27.0
- Node.js/npm: v12.20.2 (npm v6.14.11)
- OS: ubuntu
- Browser: chrome
➕ Additional Context
Related to what is done in https://github.com/yapplabs/ember-modal-dialog, see https://github.com/yapplabs/ember-modal-dialog/issues/320.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Deprecations Added in Ember 3.x
The deprecated copy function now handles array copies directly, no longer delegating to NativeArray.copy . With this deprecation, NativeArray no longer ...
Read more >Ember Changelog - GitHub
#19868 [BUGFIX] Fix a bug with the implicit injections deprecation that meant injecting a store to avoid the deprecation did not work.
Read more >Injecting dependencies into an Ember model - Stack Overflow
I'm attempting to inject dependencies into my Ember models. https://github.com/emberjs/ember.js/issues/3670, states that this is disabled.
Read more >@ember-data/debug | Yarn - Package Manager
Ember Data Changelog. 4.9.1 (2022-12-03). :bug: Bug Fix. tracking. #8314 fix: tracking package should not declare exports while v1 (@runspired) ...
Read more >Application Concerns: Dependency Injection - Ember.js
By default, Ember will attempt to instantiate a registered factory when it is looked up. When registering an already instantiated object instead of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
as workaround,
may work
Thanks @lifeart, this does the trick.