Skip to content
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

Adds aliasMethod deprecation #269

Merged
merged 2 commits into from
Feb 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions content/ember/v3/deprecate-alias-method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
id: object.alias-method
title: Deprecate `@ember/object#aliasMethod`
until: '4.0.0'
since: '3.8'
---

`@ember/object#aliasMethod` is a little known and rarely used method that allows
user's to add aliases to objects defined with `EmberObject`:

```js
import EmberObject, { aliasMethod } from '@ember/object';

export default EmberObject.extend({
foo: 123,
bar() {
console.log(this.foo);
},
baz: aliasMethod('bar'),
});
```

This can be refactored into having one function call the other directly:

```js
import EmberObject from '@ember/object';

export default EmberObject.extend({
foo: 123,
bar() {
console.log(this.foo);
},
baz() {
this.bar(...arguments);
},
});
```

Avoid defining methods directly on the class definition, since this will not
translate well into native class syntax in the future:

```js
// Do not use this, this is an antipattern! 🛑
import EmberObject from '@ember/object';

function logFoo() {
console.log(this.foo);
}

export default EmberObject.extend({
foo: 123,
bar: logFoo,
baz: logFoo,
});
```