PDA

View Full Version : How can I know when Ext.app.Application.instance is set?



cmeans
26 Oct 2013, 8:47 AM
ExtJS v4.1.3

I have custom library Proxy code that needs to access a given controller in-order to function correctly.

I pass the name of the controller in the Proxy constructor, so that it can resolve the controller later, and it's using this code to get the controller instance:


Ext.app.Application.instance.getController(this.controllerName);


However, I'm finding that there are some cases where (especially if I have to process URL parameters, and initiate some functions straight away), that Ext.app.Application.instance is undefined.

This is probably a result of a poor implementation on my part...but it's what I've got to work with at the moment.

Is there a specific event I can listen for that will let me know when the Ext.app.Application.instance property has been initialized?

Thanks.

-Chris

mitchellsimoens
28 Oct 2013, 12:58 PM
Sounds like you have a race condition. When Ext.onReady fires, that's where the Ext.app.Application.instance is set so sounds like whatever code you are executing is executing too soon.

cmeans
28 Oct 2013, 1:03 PM
I have it working fine now.

I have my own Ext.onReady closure that I create during the app onLaunch. I wait until that has fired before I try to use Ext.app.Application.instance, and that appears to be working fine now.

(I checked the source and saw that it's inside an Ext.onReady where "instance" is being set, so that seemed like a logical place for me to get into the right chain of events.)

Thanks.

-Chris