With ember-cli providing injectors for DI, I have something like this in my file app/initializers/drupal-csrf-token.js:
export default {
name: 'drupal-csrf-token',
initialize: function(container, app) {
app.inject('route', 'drupalCsrfToken', 'service:drupalCsrfToken');
app.inject('controller', 'drupalCsrfToken', 'service:drupalCsrfToken');
}
};
Usually, when you want a singleton with DI, you do something like this:
container.register('store:main', Store, { singleton: true });
However, I cannot figure out where to bind the singleton flag to the initializer so that it gets stuck.
Is it possible?
source
share