-
4 Feb 2013 5:21 PM #1
Launch and onReady fire out of order
Launch and onReady fire out of order
I have a simple MVC app, which I define in an "Sjs.apps" path that I define via Ext.Loader.setPath:
It has one view that I define as a Window:Code:Ext.define('Sjs.apps.examples.windowdebug.Main', { extend: 'Ext.app.Application', alias: 'app.exampleswindowdebug', requires: [ 'Sjs.apps.examples.windowdebug.view.WindowDebugView' ], controllers: [ ], constructor: function() { var me = this; me.win = Ext.create('widget.windowdebugview'); me.callParent(arguments); me.close = function() { me.win.close(); }; }, launch: function() { this.win.show(); } });
My launch code looks like this:Code:Ext.define('Sjs.apps.examples.windowdebug.view.WindowDebugView',{ extend: 'Ext.window.Window', alias: 'widget.windowdebugview', requires: [ 'Ext.layout.container.Border' ], width: 400, height: 300, defaultType: 'panel', layout: 'fit', initComponent: function(){ var me = this ; Ext.apply(me,{ title: 'Example Windowed Application', closable: true, closeAction: 'destroy', draggable: true, renderTo: Ext.getBody() //html: '<div><span>Example Application goes here</span></div>' }); me.callParent(); } });
In 4.0.5 and 4.0.7, this works, since the launch method of the app gets called during create before the onReady handler exits, above, as I would expect (I would expect launch to get called to open the window before I later close it within the same handler). But in 4.1.0 and 4.1.1, launch gets called after the onReady handler exits, so app1.close() fails (with an unhandled exception) because the window has not been rendered yet.Code:(function() { var appName = 'Sjs.apps.examples.windowdebug.Main', appAlias = 'app.exampleswindowdebug' ; // Load core dependencies Ext.require([ 'Ext.LoadMask', 'Ext.app.Application' ]); Ext.require(appName, function() { Ext.onReady(function() { var app1 = Ext.create(appAlias), app2 = Ext.create(appAlias) ; // Windows should display here as a result of launch getting called via Ext.create // Set a breakpoint here to see them in 4.0.5 or 4.0.7. They will not be open in // 4.1.0 or 4.1.1 and the subsequent close() calls will fail because launch does not // execute until after this onReady handler exits. app1.close(); app2.close(); }); }); })();
You might wonder why a window would be opened and closed within the same handler. Think: unit tests. I have a unit test that launches my app in onReady, performs some tests, then closes the window. It was this unit test that broke when updating from 4.0.7 to 4.1.0.Last edited by BillHubbard; 6 Feb 2013 at 11:08 AM. Reason: Correction for clarity
-
6 Feb 2013 11:29 AM #2
Fixed
Fixed
UPDATE: This was a problem in 4.1.0 and 4.1.1 but appears to be fixed in 4.1.3.
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote