-
Notifications
You must be signed in to change notification settings - Fork 49
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
Relying on unknownProperty breaks can helper #126
Comments
Hi, Another solution for your case could be defining abilities in the constructor if you are able to get all the keys. I usually follow this path. So instead of relaying on abilities.forEach((key) => {
Object.defineProperty(this, key, { get() { return this.hasAbility(key) } })
}) Let me know If that would solve your issue :) |
Hello @Exelord, I agree with you that with the soft deprecation of EmberObject this might not be the best solution but then I think there might be some confusion for other users with the current state of ember-can. Currently, the ability class still extends EmberObject itself so as a user I would expect to be able to rely on public APIs exposed by EmberObject without breakings. From my point of view, ember-can should either get rid of EmberObject and release a major release with breaking changes (this may also resolve #92) or stay backward compatible with features supported by EmberObject. What do you think ? That said, I understand this is an open source project and you might not want to do that for a small edge case you didn't encounter. Regarding your solution (thanks for it), it is in fact what I've done first, this works pretty well and I also think It's the go to solution to not rely on EmberObject. But, in our case, we also sometimes override the unknownProperty in our abilities' subclasses and that would involve a refactor that is out of scope of my initial work to get our app up to date and octane ready. Anyway, I'm totally cool with keeping my can helper override until we can afford to spend some time to refactor our abilities with your solution :) ! |
How about if we would use |
Yes, using I can open a PR, if you like ! |
Ok, cool! I will accept it :) |
@Exelord can this be closed? It looks like a PR was merged. |
First of all, thanks for writing this addon, we are relying a lot on it in our app.
While upgrading to the latest version of ember-can we came across an issue that currently breaks our app.
We rely on the unknownProperty of EmberObject to match abilities with a preloaded list we get from our backend to avoid defining all of them by hands.
To give you some insight, here's our base ability class :
Unfortunately, there was a change introduced in 2d8a197#diff-6ef2539ada25eeefeef778ae6f0aef826e9bf2ba2e8b94cf138f1ea70267de2dR21, that breaks the helper in our case.
We get the error :
This obviously happens because of our use of unknownProperty while ember-can doesn't use ember's get method to retrieve the abilities properties, removing it fixes the error.
I understand that you removed the use ember's get method to support native class but our issue can easily be fixed by checking if the ability inherits EmberObject like so :
I can open a PR with our fix if this is something you'd be okay with.
The text was updated successfully, but these errors were encountered: