-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Deprecate Computed .property()
Modifier
#375
Deprecate Computed .property()
Modifier
#375
Conversation
.property()
Modifier.property()
Modifier
Completely in favor of this. It's super weird. I offer to help with the deprecation if approved. |
Agree as well! Mainly bike shedding here, but what about this function signature: filter(filteredPropertyKey: string, callback: Function, additionalDependentKeys?: string[]): ComputedProperty; I would prefer it strongly over the one mentioned in "Alternatives", and on par with the one proposed. Maybe a tad easier to refactor existing code, by moving the additional dependent keys form |
@simonihmig my only concern with that API is looking forward to usage with decorators. Currently, we allow these macros to use the function they are being applied to as the filter function in @filter('key', function() {
// filter code...
})
filterProp;
// or
@filter('key')
filterProp() {
// filter code...
} In this usage, the function always comes last lexically, so we'd end up with: @filter('key', ['additional', 'keys'])
filterProp() {
// filter code...
} I think the array makes it pretty readable though, so I wouldn't be opposed to changing at all. Just need to factor in that these will probably be changing soon. Also, decorator APIs are not set in stone, and still need to be RFCd, so that form could be removed in the future. |
I really like the array form for the decorator, as it should be really easy to document and teach.
Would the following be disallowed?
This variation on the proposed alternative makes it very clear that the first key is required and delineates its role clearly. It is more readable because the function is last, so you aren't having to walk back across a function body from other parameters to find the beginning of the call. (APIs always carry less "cognitive load" if you can observe and dismiss all the "short" parameters with a single glance before digging into the meat of the function.) It would work well with syntax completion, and would be very easy to teach. It also happens to be the pure functional equivalent of the array form of the decorator. |
I agree, that form is the least complicated and easiest to read IMO, plus it works really well in decorator form. I'll update the RFC accordingly, thanks for the feedback @RalphMack and @simonihmig 😄 |
|
||
As mentioned above, macros which receive a callback function as an argument are | ||
the only valid use of `.property()` in current Ember. Currently, there are two | ||
such macros in Ember core: `map` and `filter`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something here, but couple comments:
-
It looks like all
ComputedProperty
instances attach theirdependentKey
using.property
.Does that mean that the class itself needs to be changed to accept dependentKeys as constructor arguments?
-
Secondly, in the case of
arrayMacros
, it looks like the only dependentKey actually being attached using.property()
is the key that's originally passed in (appended with.[]
). Which to me sounds like the proposal foradditionalDependentKeys
is unnecessary?
https://github.com/emberjs/ember.js/blob/master/packages/%40ember/object/lib/computed/reduce_computed_macros.js#L56
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
This is more of an implementation detail which is why I didn't address it in the RFC, but yes this would have to change. The most direct way forward would be to make the
property()
api private (e.g._property
) but we could change the constructor as well. -
The key difference with the array macros is that they receive arbitrary functions as arguments, and have no way of knowing if those functions introduce additional dependencies. Take the example from the RFC:
foo: filter('strings', function(s) { return s.includes(this.filterText); }).property('filterText')
The
filter
macro has no way to know that it should update wheneverfilterText
has changed, it only knows that whenever thestrings
array has updated it should as well. Everything that happens inside the function argument is a black box to it, completely opaque. This can affect any macro which receives arbitrary functions as an argument, it just so happens that the only ones in Ember's core library aremap
andfilter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, that makes sense, thanks for explaining.
For what it's worth, using filter().property()
does not seem like a common case to me. Considering that this is is a breaking change already, a couple other alternatives might be:
recommend usingEmber.computed
for this case insteadfilter/map receiven
string args followed by a function arg, where the first is the enumerable property, and all following string args are dependentKeys. This would be more closely aligned with the Ember.computed API.
I see the additional conversation about syntax and it covers my suggestions too, sorry for the noise!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely not a common case, but ember-decorators
have received reports of users using it this way (that's actually how I found out about this issue). But yes, those are both reasonable alternatives, I'll add them to the alternatives section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that this is is a breaking change already
I do not see any breaking changes proposed here? Existing syntaxes should be completely compatible with a deprecation warning, have we missed something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing computed().property()
would technically be breaking which is what I think @mehulkar was referring too, but that would happen in Ember v4 and there would be a very long overlap period with the deprecation warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I was referring to removing .property()
, but you're right there's a different rfc for that I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the different RFC deprecates function prototype extensions, which are actually subtly different:
foo: function() {
}.property('bar'), // calls a method that was added to Function.prototype
bar: computed(function() {
}).property('baz') // calls a method on the ComputedProperty class instance
Discussed this at the core team meeting yesterday, and we are in favor of moving this into final comment period. |
No new concerns have been brought forward, the time has come to merge! |
Bumps [ember-source](https://github.com/emberjs/ember.js) from 3.8.0 to 3.9.0. <details> <summary>Release notes</summary> *Sourced from [ember-source's releases](https://github.com/emberjs/ember.js/releases).* > ## v3.9.0-beta.5 > ### CHANGELOG > > - [#17733](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17733) [BUGFIX] Assert on use of reserved component names (`input` and `textarea`) > > ## v3.9.0-beta.4 > ### CHANGELOG > > - [#17710](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17710) [BUGFIX] Allow accessors in mixins > > ## v3.9.0-beta.3 > ### CHANGELOG > > - [#17684](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17684) [BUGFIX] Enable maximum rerendering limit to be customized. > - [#17691](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17691) [BUGFIX] Ensure tagForProperty works on class constructors > > ## v3.9.0-beta.2 > ### CHANGELOG > > - [#17618](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17618) [BUGFIX] Migrate autorun microtask queue to Promise.then > - [#17649](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17649) [BUGFIX] Revert decorator refactors > > ## v3.9.0-beta.1 > ### CHANGELOG > > > - [#17470](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17470) [DEPRECATION] Implements the Computed Property Modifier deprecation RFCs > * Deprecates `.property()` (see [emberjs/rfcs#375](https://github.com/emberjs/rfcs/blob/master/text/0375-deprecate-computed-property-modifier.md) > * Deprecates `.volatile()` (see [emberjs/rfcs#370](https://github.com/emberjs/rfcs/blob/master/text/0370-deprecate-computed-volatile.md) > * Deprecates computed overridability (see [emberjs/rfcs#369](https://github.com/emberjs/rfcs/blob/master/text/0369-deprecate-computed-clobberability.md) > - [#17488](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17488) [DEPRECATION] Deprecate this.$() in curly components (see [emberjs/rfcs#386](https://github.com/emberjs/rfcs/blob/master/text/0386-remove-jquery.md)) > - [#17489](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17489) [DEPRECATION] Deprecate Ember.$() (see [emberjs/rfcs#386](https://github.com/emberjs/rfcs/blob/master/text/0386-remove-jquery.md)) > - [#17540](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17540) [DEPRECATION] Deprecate aliasMethod > - [#17487](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17487) [BUGFIX] Fix scenario where aliased properties did not update in production mode </details> <details> <summary>Changelog</summary> *Sourced from [ember-source's changelog](https://github.com/emberjs/ember.js/blob/master/CHANGELOG.md).* > # Ember Changelog > > ### v3.9.0-beta.5 (March 25, 2019) > > - [#17733](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17733) [BUGFIX] Assert on use of reserved component names (`input` and `textarea`) > > ### v3.9.0-beta.4 (March 11, 2019) > > - [#17710](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17710) [BUGFIX] Allow accessors in mixins > > ### v3.9.0-beta.3 (March 4, 2019) > > - [#17684](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17684) [BUGFIX] Enable maximum rerendering limit to be customized. > - [#17691](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17691) [BUGFIX] Ensure tagForProperty works on class constructors > > ### v3.9.0-beta.2 (February 26, 2019) > > - [#17618](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17618) [BUGFIX] Migrate autorun microtask queue to Promise.then > - [#17649](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17649) [BUGFIX] Revert decorator refactors > > ### v3.9.0-beta.1 (February 18, 2019) > > - [#17470](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17470) [DEPRECATION] Implements the Computed Property Modifier deprecation RFCs > * Deprecates `.property()` (see [emberjs/rfcs#375](https://github.com/emberjs/rfcs/blob/master/text/0375-deprecate-computed-property-modifier.md) > * Deprecates `.volatile()` (see [emberjs/rfcs#370](https://github.com/emberjs/rfcs/blob/master/text/0370-deprecate-computed-volatile.md) > * Deprecates computed overridability (see [emberjs/rfcs#369](https://github.com/emberjs/rfcs/blob/master/text/0369-deprecate-computed-clobberability.md) > - [#17488](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17488) [DEPRECATION] Deprecate this.$() in curly components (see [emberjs/rfcs#386](https://github.com/emberjs/rfcs/blob/master/text/0386-remove-jquery.md)) > - [#17489](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17489) [DEPRECATION] Deprecate Ember.$() (see [emberjs/rfcs#386](https://github.com/emberjs/rfcs/blob/master/text/0386-remove-jquery.md)) > - [#17540](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17540) [DEPRECATION] Deprecate aliasMethod > - [#17487](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17487) [BUGFIX] Fix scenario where aliased properties did not update in production mode </details> <details> <summary>Commits</summary> - [`8df20e9`](emberjs/ember.js@8df20e9) Release v3.9.0 - [`2b9ee17`](emberjs/ember.js@2b9ee17) Add v3.9.0 to CHANGELOG - [`bfe670c`](emberjs/ember.js@bfe670c) Bump router_js - [`2f8b8ba`](emberjs/ember.js@2f8b8ba) [DOCS beta] remove component nesting docs - [`0270001`](emberjs/ember.js@0270001) Release v3.9.0-beta.5 - [`1e2672c`](emberjs/ember.js@1e2672c) Add v3.9.0-beta.5 to CHANGELOG - [`37d0a11`](emberjs/ember.js@37d0a11) Fix docs test - [`86999a7`](emberjs/ember.js@86999a7) Post-cherry-pick lint fixup - [`fff729a`](emberjs/ember.js@fff729a) [DOC RouteInfo] Fix grammar, spelling, and formatting - [`b179dfd`](emberjs/ember.js@b179dfd) added param "name of the block" for the API document of has-block and has-blo... - Additional commits viewable in [compare view](emberjs/ember.js@v3.8.0...v3.9.0) </details> <br /> [![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=ember-source&package-manager=npm_and_yarn&previous-version=3.8.0&new-version=3.9.0)](https://dependabot.com/compatibility-score.html?dependency-name=ember-source&package-manager=npm_and_yarn&previous-version=3.8.0&new-version=3.9.0) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) If all status checks pass Dependabot will automatically merge this pull request during working hours. [//]: # (dependabot-automerge-end) --- **Note:** This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit. You can always request more updates by clicking `Bump now` in your [Dependabot dashboard](https://app.dependabot.com). <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme Additionally, you can set the following in the `.dependabot/config.yml` file in this repo: - Update frequency (including time of day and day of week) - Automerge options (never/patch/minor, and dev/runtime dependencies) - Pull request limits (per update run and/or open at any time) - Out-of-range updates (receive only lockfile updates, if desired) - Security updates (receive only security updates, if desired) Finally, you can contact us by mentioning @dependabot. </details> [//]: # (dependabot-no-ci-start) ---⚠️ **Dependabot won't automerge this PR as it didn't detect CI on it**⚠️ You have automerging enabled for this repo but Dependabot didn't detect any CI statuses or checks. You can disable automerging on this repo by editing the `.dependabot/config.yml` file in this repo. [//]: # (dependabot-no-ci-end)
Rendered