-
-
Notifications
You must be signed in to change notification settings - Fork 406
Description
- Proposed Target: Ember v5.0.0
- Alternative: Tracked Properties,
macro-decorators
Computed properties have been an Ember mainstay since the beginning of the framework. They were how Ember accomplished reactivity, and they have been incredibly useful for deriving state in a declarative way. Tracked properties iterate on CPs, giving us the same benefits with less boilerplate and more flexibility. CPs add a large amount of complexity to the framework overall, and a hefty chunk of code, so removing them will be a major win from a maintenance perspective and a bundle size perspective.
Migration Path
For the most part, migrations from CPs to TPs should be pretty straightforward. There will be gotchas, particularly around caching since getters for TPs do not cache. We should make sure we have lots of guides showing users how to migrate, and how to debug tracked properties (especially in cases of infinite rerenders/invalidations).
Part of deprecating CPs also includes deprecating CP macros, such as @and(), @or(), @filter(), @alias, etc. These macros were very useful prior to TPs because they allowed users to avoid a large amount of boilerplate, but since the boilerplate has been reduced so much with TPs, they may not make much sense in most cases anymore. They also represent a fair amount of bundle size, and a decent maintenance burden.
This pre-RFC proposes that Ember should not continue to provide computed property macros. Since any getter should work with tracked properties, users can instead rely on a generic decorator libraries, like macro-decorators. These libraries don't need to be Ember specific, or maintained by the Ember core team, and can instead be community driven. This would also allow them to experiment much more (similar to ember-macro-helpers), without relying on private APIs or causing additional issues down line since it's Just JavaScript™️.
Deprecation Timeline
Computed properties are highly prolific in Ember code today, so it will take quite some time for users to migrate from them. This is why this pre-RFC proposes that we deprecate them for removal in v5.0.0, which should give the community plenty of time to adopt the new idioms and migrate away from CPs.