Skip to content Skip to sidebar Skip to footer

Does Ember Octane Route Class Support Using Mixins?

I am upgrading to Ember Octane and I understand that mixins have been deprecated. I will continue to use them until I figure out how to replace them. In the meantime, I would like

Solution 1:

Native class syntax does not directly have an equivalent for the Ember mixin system. If you want to continue using mixins as you convert to Octane, you can do so by mixing classic class extension syntax with native class syntax:

Try

importRoutefrom'@ember/routing/route';
importAbcAuthenticatedRouteMixinfrom'../../mixins/abc-authenticated-route-mixin';

exportdefaultclassChangePasswordRouteextendsRoute.extend(AbcAuthenticatedRouteMixin) {

    model() {

        return {
            oldPassword: '',
            newPassword: '',
            confirmPassword: ''
        };
    }
}

In addition, some new framework classes, such as Glimmer components, do not support Ember mixins at all. In the future, mixins will be removed from the framework, and will not be replaced directly. For apps that use mixins, the recommended path is to refactor the mixins to other patterns, including:

Pure native classes, sharing functionality via class inheritance. Utility functions which can be imported and used in multiple classes. Services which can be injected into multiple classes, sharing functionality and state between them.

Post a Comment for "Does Ember Octane Route Class Support Using Mixins?"