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

Remove .property() #19671

Merged
merged 1 commit into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
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
85 changes: 0 additions & 85 deletions packages/@ember/-internals/metal/lib/computed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,81 +733,6 @@ class ComputedDecoratorImpl extends Function {
return this;
}

/**
Sets the dependent keys on this computed property. Pass any number of
arguments containing key paths that this computed property depends on.

Example:

```javascript
import EmberObject, { computed } from '@ember/object';

class President {
constructor(firstName, lastName) {
set(this, 'firstName', firstName);
set(this, 'lastName', lastName);
}

// Tell Ember that this computed property depends on firstName
// and lastName
@computed().property('firstName', 'lastName')
get fullName() {
return `${this.firstName} ${this.lastName}`;
}
}

let president = new President('Barack', 'Obama');

president.fullName; // 'Barack Obama'
```

Classic Class Example:

```javascript
import EmberObject, { computed } from '@ember/object';

let President = EmberObject.extend({
fullName: computed(function() {
return this.get('firstName') + ' ' + this.get('lastName');

// Tell Ember that this computed property depends on firstName
// and lastName
}).property('firstName', 'lastName')
});

let president = President.create({
firstName: 'Barack',
lastName: 'Obama'
});

president.get('fullName'); // 'Barack Obama'
```

@method property
@deprecated
@param {String} path* zero or more property paths
@return {ComputedProperty} this
@chainable
@public
*/
property(this: Decorator, ...keys: string[]) {
deprecate(
'Setting dependency keys using the `.property()` modifier has been deprecated. Pass the dependency keys directly to computed as arguments instead. If you are using `.property()` on a computed property macro, consider refactoring your macro to receive additional dependent keys in its initial declaration.',
false,
{
id: 'computed-property.property',
until: '4.0.0',
url: 'https://deprecations.emberjs.com/v3.x#toc_computed-property-property',
for: 'ember-source',
since: {
enabled: '3.9.0-beta.1',
},
}
);
(descriptorForDecorator(this) as ComputedProperty)._property(...keys);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but _property could be refactored to be more strictly internal now

return this;
}

/**
In some cases, you may want to annotate computed properties with additional
metadata about how they function or what values they operate on. For example,
Expand Down Expand Up @@ -1010,16 +935,6 @@ class ComputedDecoratorImpl extends Function {
libraries that depend on or use Ember, since there is no guarantee that the user
will have [prototype Extensions](https://guides.emberjs.com/release/configuring-ember/disabling-prototype-extensions/) enabled._

The alternative syntax, with prototype extensions, might look like:

```js
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName')
```

This form does not work with native decorators.

@method computed
@for @ember/object
@static
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,26 +363,6 @@ moduleFor(
obj2.destroy();
}

['@test can declare dependent keys with .property()'](assert) {
let Obj;

expectDeprecation(() => {
Obj = EmberObject.extend({
foo: computed(function () {
return this.bar;
}).property('bar'),
});
}, /Setting dependency keys using the `.property\(\)` modifier has been deprecated/);

let obj = Obj.create({ bar: 1 });

assert.equal(obj.get('foo'), 1);

obj.set('bar', 2);

assert.equal(obj.get('foo'), 2);
}

['@test native getters and setters work'](assert) {
let MyClass = EmberObject.extend({
bar: 123,
Expand Down
1 change: 0 additions & 1 deletion tests/docs/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ module.exports = {
'positionalParams',
'preventDefault',
'promise',
'property',
'pushObject',
'pushObjects',
'pushState',
Expand Down