adopted-ember-addons / ember-cli-flash

Simple, highly configurable flash messages for ember-cli
https://www.npmjs.com/package/ember-cli-flash
MIT License
354 stars 113 forks source link

Remove `injectionFactories` #380

Closed sandydoo closed 2 years ago

sandydoo commented 2 years ago

As of Ember 4.0, implicit injection with application.inject has been disabled. This PR removes the long-deprecated implicit injection of the flash messages service into all routers, controllers, views, and components.

Migration guide

You should inject the service yourself wherever you need it.

For example, in a component:

import Component from '@glimmer/component';
import { inject as service } from '@ember/service';

export default class FlashComponent extends Component {
  @service flashMessages;
}

Or in a controller:

import Controller from '@ember/controller';
import { inject as service } from '@ember/service';

export default class ApplicationController extends Controller {
  @service flashMessages;
}

Impact considerations

The default option for injectionFactories was ['route', 'controller', 'view', 'component']. So implicit injection was enabled by default, despite being deprecated. It’s likely that some apps will break if they didn’t inject the service correctly and accidentally relied on this feature. In Ember 4.0, this default injection throws a deprecation warning. Fixing the error requires setting injectionFactories to [], an option that hasn’t been documented in years.