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

Use native ES6 classes instead of EmberObject for Ability #138

Open
Gorzas opened this issue May 17, 2021 · 3 comments
Open

Use native ES6 classes instead of EmberObject for Ability #138

Gorzas opened this issue May 17, 2021 · 3 comments

Comments

@Gorzas
Copy link
Contributor

Gorzas commented May 17, 2021

The latests versions of EmberJS are deprecating the use of EmberObject and Ember computed properties to use native ones instead. This could be a good improvement, also if we think in making it easier for users of other frameworks to start using EmberJS. An start could be changing the Ability class to use ES6 native classes.

I think this changes should be for a potential new major version (4.0.0 of ember-can) as it could remove some compatibilities with older versions of EmberJS. What do you think?

@tben
Copy link

tben commented May 30, 2021

Btw, you can just use the ability class just like before.

import { Ability } from 'ember-can';

export default class AuthUser extends Ability {
    get canUserManage() {
        return true;
    }
}

@Gorzas
Copy link
Contributor Author

Gorzas commented Jun 28, 2021

I've migrated Ability to ES6 class but it still needs more work to be done. Right now, it still depends on EmberObject:

import EmberObject, { get }  from '@ember/object';
import { camelize } from '@ember/string';

export default class Ability extends EmberObject {
  model = null;

This may be because this line but I decided it's a problem worth to be solved later.

And it's also being tested using computed properties instead of the new tracked syntax.

@Gorzas
Copy link
Contributor Author

Gorzas commented Jun 29, 2021

Just as reminder there are two changes left to finish this issue as talked about in the PR:

  • remove EmberObject dependency on Can service.
  • fix linter errors.

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

No branches or pull requests

2 participants