You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vareo=new$E.O;// There are four built in methods: on, off, set, get.eo.on('prop',function(val,prev,name){console.log('name: "'+name+'", previous value: "'+prev+'", new value: "'+val+'"');});eo.set('prop','ololo');> name: "prop",previous value: "undefined",newvalue: "ololo"eo.set('prop','piupiu');> name: "prop",previous value: "ololo",newvalue: "piupiu"// You can touch the property with some value without changing it.eo.trigger('prop','hahaha','prevprev');> name: "prop",previous value: "prevprev",newvalue: "hahaha"eo.trigger('prop','hihihi');> name: "prop",previous value: "undefined",newvalue: "hihihi"// These properties are stored in a special container.console.log(eo.prop);>undefinedconsole.log(eo.get('prop'));>piupiu
Extending
varMyEO=$E.O.extend({init: function(arg1,arg2){// init() method is called with new instance creation.console.log('args: "'+arg1+'" and "'+arg2+'"');},something: 'hello',another: 'world',method: function(arg){returnthis.something+arg+this.another;}});varmyeo=newMyEO('aaa','bbb');> args: "aaa"and"bbb"console.log(myeo.method('_'));>hello_worldvarMyMyEO=MyEO.extend({something: 'hi'});varmymyeo=newMyMyEO('11','22');> args: "11"and"22"console.log(mymyeo.method('|'));>hi|worldconsole.log(myeoinstanceof$E.O);>trueconsole.log(myeoinstanceofMyEO);>trueconsole.log(mymyeoinstanceofMyEO);>trueconsole.log(mymyeoinstanceofMyMyEO);>trueconsole.log(myeoinstanceofMyMyEO);>false