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

Proposal: New keyword for Mixins #7798

Closed
ivan-pro opened this issue Apr 4, 2016 · 1 comment
Closed

Proposal: New keyword for Mixins #7798

ivan-pro opened this issue Apr 4, 2016 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@ivan-pro
Copy link

ivan-pro commented Apr 4, 2016

Following the mixin sample from here, I propose a new keyword for implementing mixins. The goal is to keep the code as clean as possible by letting the compiler know that applyMixins has to be included in the codebase and it must be called. Let's say the keyword is 'mixin', the aforementioned example would then be brought down to

class SmartObject mixin Disposable, Activatable {
    constructor() {
        setInterval(() => console.log(this.isActive + " : " + this.isDisposed), 500);
    }

    interact() {
        this.activate();
    }
}

An alternative way to declare it in order to avoid confusion with implements/extends:

class SmartObject {
    mixin Disposable
    mixin Activatable 

    constructor() {
        setInterval(() => console.log(this.isActive + " : " + this.isDisposed), 500);
    }

    interact() {
        this.activate();
    }
}

The compiler would then add the applyMixins function and call it as shown in the article.

@Arnavion
Copy link
Contributor

Arnavion commented Apr 4, 2016

See #2919 and the comment at #311 (comment)

@mhegazy mhegazy added the Duplicate An existing issue was already created label Apr 5, 2016
@mhegazy mhegazy closed this as completed Apr 5, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants