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 computed property overrides #1841

Conversation

backspace
Copy link
Contributor

This fixes the deprecation warnings described here, from Ember 3.8:
https://deprecations.emberjs.com/v3.x/#toc_computed-property-override

You can see in the Travis logs that the warnings are gone by comparing the log of this most recent run on master, which has 222 instances of “overriden” (sic), to the log of this PR run, which has 0!

I chose to follow a pattern of adding a property to this with the same attribute name with Override appended. This allows the get to check if the overridden property exists before sending the default if it doesn’t. It’s repetitive and a bit unwieldy. Since it’s the same pattern for each computed property, it could be extracted. Let me know if you think that’s desirable or if there are any other changes you’d like to see.

Thanks for this project, it’s great to have around!

@backspace backspace force-pushed the computed-property-override-deprecation branch from 78506c9 to a026125 Compare May 11, 2019 20:42
@richard-viney
Copy link
Contributor

Great! As you point out, doing this with a computed property macro would end up being less verbose.

@backspace
Copy link
Contributor Author

Agreed, that’s my preference, but I’m not a maintainer so I’ll wait for confirmation that they’d be into having that kind of abstraction in the codebase 😀

Copy link
Member

@marcoow marcoow left a comment

Choose a reason for hiding this comment

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

I think all of the CPs with _ prefixes are only overridden in tests. As they are private API anyway, I'd say it should be fine to replace them with regular properties and set them in init or so which should be much simpler than turning them all into writeable CPs.

set(key, value) {
this.routeAfterAuthenticationOverride = value;
return value;
}
}),
Copy link
Member

Choose a reason for hiding this comment

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

Could this not be replaced with

routeAfterAuthentication: Configuration.routeAfterAuthentication,

simply? I can't remember why this was made a CP in the first place…

backspace added a commit to backspace/ember-simple-auth that referenced this pull request Jun 4, 2019
backspace added a commit to backspace/ember-simple-auth that referenced this pull request Jun 4, 2019
@backspace
Copy link
Contributor Author

I made those changes but maybe getOwner(this) doesn’t work inside init? I’ve run out of time for this at the moment but I’ll see if I can figure it out at some point 😞

@backspace
Copy link
Contributor Author

backspace commented Jun 4, 2019

There’s more than one thing wrong but it’s true that getOwner won’t work in a mixin because this doesn’t yet exist. I looked at the arguments and the first one for a route mixin is store, so getOwner(store) could work there, but that seems scandalous 😳

(Also, that doesn’t work with createWithContainer elsewhere)

@marcoow
Copy link
Member

marcoow commented Jun 24, 2019

I think using getOwner(this) in init in a mixin should be fine after this._super(...arguments);. I'm not really sure what the problem is here…

addon/mixins/authenticated-route-mixin.js Outdated Show resolved Hide resolved
addon/mixins/authenticated-route-mixin.js Outdated Show resolved Hide resolved
addon/mixins/unauthenticated-route-mixin.js Outdated Show resolved Hide resolved
@backspace
Copy link
Contributor Author

I can’t explain it but I made 4f48367 to add some logging that shows that getOwner(this) is strangely returning false in init, you can see it here in this Travis job. But maybe it’s a red herring, as I think 18db3c4 addressed the failures.

I needed 4379cf3 to get the lint and floating dependencies tests running on Travis, maybe some dependency has dropped support for Node 6? I’ve since removed it, but before that, the tests were passing apart from the FastBoot one but the failures look the same as those on the most recent master job.

I’m unsure about the Node 6 vs 8 thing but could easily open a PR to change that if it’s desirable.

@josemarluedke
Copy link
Contributor

These changes look good! Any change to get them merged soon? Thanks.

@josemarluedke
Copy link
Contributor

I just came across a problem with routeAfterAuthentication not working in an Octane app. Using the changes in this branch in conjunction with changes from master, the problem goes away.

@Turbo87
Copy link
Collaborator

Turbo87 commented Jul 17, 2019

closing in favor of #1900

@Turbo87 Turbo87 closed this Jul 17, 2019
@josemarluedke
Copy link
Contributor

I believe #1900 was just a subset of the changes here. There are a few more deprecations going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants