The behaviour for component factory caching is inconsistent between the definitionCache in the GlimmerEnvironment and the factoryCache in the container. The container does not cache factories with dynamic injections, whereas the GlimmerEnvironment does.
// initializers.app-init.js
import Ember from 'ember';
var id = 0;
export function initialize(application) {
application.register('foo:bar', Ember.Object.extend({
id: Ember.computed(function() {
return ++id;
})
}), { singleton: false });
application.inject('component', 'foo', 'foo:bar');
}
export default {
name: 'app-init',
initialize
};
// my-component.hbs
id: {{foo.id}}
// templates.application.hbs
{{ my-component }}
{{ my-component }}
{{ my-component }}
In Ember 2.9 the output is:
id: 1
id: 2
id: 3
In Ember 2.10 the output is:
id: 1
id: 1
id: 1
See Ember Twiddle
And failing test
We're refactoring our code that uses this pattern, so don't expect this issue to affect us - this is more an FYI
@chancancode this actually seems like we will need to do something regarding the definitionCache to fix.
looks like fixed in 2.13.*
Can you confirm @adamjmcgrath ?
No sorry, I'm in the middle of the Pacific. Back September :)
I work with @adamjmcgrath. I can check it out today
Sorry for delay.
I can confirm it is working in 2.13.*. The twiddle now behaves as it did in 2.9.
Thanks for letting us know 馃憤
Most helpful comment
I work with @adamjmcgrath. I can check it out today