Skip to content

Proposal: deprecate Ember.alias and add Ember.computed.alias and Ember.aliasMethod #1725

@lukemelia

Description

@lukemelia

Problem

Ember.alias fails unexpectedly in some cases. For example, it cannot be used to alias a property that will be defined later. e.g.

Ember.ControllerMixin.reopen({
  model: Ember.alias('content')
});
controller = Ember.Controller.create({
  content: 'foo'
});
controller.get('model') //=> undefined

This is due to Alias descriptors being processed when mixins are merged (see 'followAlias' here) and after discussing with @kselden and @stefanpenner there does not seem to be a good way to make this work as expected while also supporting Ember.alias ability to alias method names.

Solution

To address this, we propose adding deprecation warnings to Ember.alias and introducing two new methods:

Ember.computed.alias(propertyPath)

Synthesizes a computed property dependent on the propertyPath and returning the value of the propertyPath. In the future, this could potentially be optimized in certain cases by reusing the descriptor of the target property.

Ember.aliasMethod(methodName)

Synthesizes a method pointing to the specified method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions