View Full Version : Extend Ext.util.Observable addListeners method, how to proceed?

6 Feb 2015, 11:52 AM

I have been trying for awhile to extend addListener method from Ext.util.Observable.

While I suppose it is a bad idea to do this, let me explain the situation. We have a desktop Ext JS 4.2 app MVC that we started using in a WebView for an iOS application. I know it isn't the recommended way, we should probably use Sencha Touch but it works surprisingly very well and saved us alot of time.

One down side is that we use 'click' events everywhere and iOS have a laggy responsive to this. I tried changing them for 'touchend' and of course the interaction lag disappeared. While I could go on and change every myCmp.on('click') to 'touchend' it doesnt fix the click: listeners used in configs.

So I thought I would just test the browser for touch event and switch all clicks event for touchend then call the parent. I was going to try this in addListener from Ext.util.Observable but I cant figure out how to do this...

Tried all these:

Ext.define('app.util.CustomObservable', {
extend: 'Ext.util.Observable',
addListener: function () { console.debug("test"); }

addListener: function () { console.debug("test"); }

I can override it but that doesn't seem like a good way to do it, I dont want to play too much into the addListener code.

Please help or is my solution flawed? :P

6 Feb 2015, 12:08 PM
Actually Im not even sure anymore it is the right place to add it.

We use some myComp.getEl().on('click') also and they do not seem to pass through Observable.addListener but instead through Ext.EventManager.addListener....

Is there a place I can hook on to catch them all?

6 Feb 2015, 3:59 PM
Not sure its possible at all... I just want to fire my click event with touchend instead, but I still want every regular component to respond to click so button and such keep working :/