I'd like to check if the object x
implements (is instance of) the mixin MyInterface
:
Ext.define('MyInterface', {
interfaceMethod: Ext.emptyFn
});
Ext.define('Foo', {
mixins: {
myInterface: 'MyInterface'
}
});
var x = new Foo();
doesn't work work:
console.log(x instanceof MyInterface);
ugly workaround:
var isInstanceOfMyInterface = false;
for (var i in x.mixins) {
if (x.mixins[i].$className == 'MyInterface') {
isInstanceOfMyInterface = true;
}
}
console.log(isInstanceOfMyInterface);
The workaround has one major issue: it doesn't work if a subclass of MyInterface is used.