http://filip.nedyalkov.net/creationcycle/ - view source is enabled, download and see the traces
Ok so here is what happens in this application:
Some elements are created in the main application and also a module is loaded. As soon as it is ready the button in the main app goes visible. When you click it the module is added to the main application.
There is where it gets weird. If the module loader is not added to the main application before the module is ready, everything I've set into the module gets created kinda randomly. For example if I have a button in the module, it should fire button created and then module created, but here it doesn't sometimes. Check out the application I've provided to see what I mean.
I think that it shouldn't matter if the module loader is added or not, and the module should fire the creation complete events in the normal order, from bottom to top (top is the module itself).
So I hope someone familiar with modules life cycle behaviour could say if what I see is a bug or not and how it can be fixed. Of course I could add the module loader before the module is loaded but make the moduleloader visible=false, and when I need it visible=true, but that's not the point here.