Skip to content

Instantly share code, notes, and snippets.

@pjetr
Created September 3, 2013 14:45
Show Gist options
  • Save pjetr/6424911 to your computer and use it in GitHub Desktop.
Save pjetr/6424911 to your computer and use it in GitHub Desktop.
enyo extending as suggested in the enyojs channel
enyo.kind({
name: "pjetr.Object",
kind: enyo.Object,
bubble: function(inEventName, inEvent, inSender){
console.log(arguments);
},
create: function(){
this.inherited(arguments);
enyo.mixin(this, new enyo.Component);
},
});
var obj = new pjetr.Object();
@DimitrK
Copy link

DimitrK commented Sep 3, 2013

There must be another parameter set to true in mixin() to not overwritte existing methods.

The way I am proposing is more JavaScript specific than framework specific. In order to call function from super class you need to capture it on you closure before you overwritte it. In the closure of bubbleUp now is the super class call instead of the one that is exposed from the object. Notice the this.bubbleUp.apply(this, arguments); refers to the superclass

enyo.kind({
    name: "pjetr.Object", 
    kind: enyo.Object, 
    bubbleUp: function(inEventName, inEvent, inSender){
        console.log(arguments); 
        this.bubbleUp.apply(this, arguments);
    },
    constructor: function(){
        enyo.mixin(this, new enyo.Component, true);
        this.inherited(arguments);
    },
});
var obj = new pjetr.Object();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment