voger
voger

Reputation: 676

Is there any way to restrict mixins as to compatible classes?

Let's say I want to define a new mixin that extends qx.ui.basic.Atom capabilities. This mixin will have functionality that applies only to qx.ui.basicAtom and it's subclasses an'd doesn't make sense for other classes. Is there any way to restrict the mixing to be allowed only to qx.ui.basic.Atom subclasses?

Upvotes: 0

Views: 51

Answers (1)

voger
voger

Reputation: 676

Never mind, I found it. In the mixin constructor we can do

construct: function (){
    if (qx.core.Environment.get("qx.debug")) {
        this.assertInstance(this, qx.ui.basic.Atom, "Error: This mixin can be included only in instances of qx.ui.basic.Atom")
    }
},

Upvotes: 2

Related Questions