-
-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intent to RFC: Deprecate Mixins #534
Labels
Comments
Was this supposed to be decorators? |
Definitely not, thanks for catching that, updated! |
Leaving this open since it's high priority. We should fast track an RFC for this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Mixins have been considered an antipattern in Ember for quite some time, for a variety of reasons. To sum them up:
Ultimately, the mixin pattern was overused in Ember applications, and Ember's particular implementation of that pattern had quirks that were used (such as state sharing) when the probably should not have been.
Migration Path
Generally speaking, we should encourage users to migrate away from the mixin pattern. Multiple inheritance is tricky in every language, and especially so in JavaScript. If a problem can be solved by sharing helper functions or services, this should be the recommended and idiomatic approach.
However, there are still (rare) cases where the mixin pattern would make sense. For these cases, we should recommend that users write class decorators. Class decorators, in the current stage 1 transforms, are functions that receive the class definition, and return a new class definition. Users can use dynamic class definitions inside of these to extend the class they are passed:
These can be applied today using class decorator syntax:
In the future, when decorator syntax moves to stage 3 and changes, these class decorators will likely need to be updated. However, since these definitions are functions, they can also be called directly:
Making them pretty future proof.
Deprecation Timeline
This pre-RFC suggests we remove mixins in Ember v4.0.0, but that is a bit of an aggressive timeline. While mixin usage is not as common as it once was, it still exists throughout the ecosystem and may take some time to migrate away from, especially if we want users to migrate away from the mixin pattern altogether. If we push for a quick deprecation, we may see a lot of class decorators being written.
The alternative would be to deprecate mixins for removal at the same time as
EmberObject
, which will likely be in v5.0.0 at the earliest.The text was updated successfully, but these errors were encountered: