Hey,
would it be desirable to have an option to disable initializers?
I have a bunch of initializers of which some are disabled in certain environments (for example Piwik stats in development mode). So I see myself writing code like this over and over again:
var piwikEnabled = MyProjectENV.ENABLE_ANALYTICS;
if (piwikEnabled) {
Ember.debug('Init Piwik');
} else {
Ember.debug('Skip Piwik');
return;
}
[...]
This gets even worse if you have dependent initializers and need to check for “basis” features to be enabled. So what I am suggesting here, is to add a enabled boolean flag to the initializer object:
export default {
name: 'pipeline',
enabled: MyProjectEnv.ENABLE_PIPELINE,
initialize: function (container, application) {
[...]
}
}
export default {
name: 'task-xyz',
after: 'pipeline'
initialize: function (container, application) {
[...]
}
Then if you set MyProjectEnv.ENABLE_PIPELINE
to false it would disable the pipeline
initializer and automatically the task-xyz
as we already know it depends on the pipeline
because of the after
specification. As Ember already builds up a dependency graph it should be possible to cut of the whole branch of a disabled node.
What do you think? Is there a chance to see this go upstream if I worked on it?
Best regards, Dominik