File IO Opration.
Hi,
In my application, there is Singleton class (AppUitls.as) which
reads config.xml and store value in local variables to access
within App from anywhere.
On application context startup() I mapped AppUtils class as
singleton. But as File read operation is Event based (FileStream),
the other injected classes get initialized before FileStream's
Event.COMPLETE event fires and my other class constructor uses
variables from AppUitls.as class for initialization. And
application fails as null values are there in AppUtils class
variables.
Am I doing anything wrong? Or there is a way to first let the
files IO operation to complete and then start injecting other
classes?
Thanks,
Indrajit
Comments are currently closed for this discussion. You can start a new one.
2 Posted by neil on 01 Jun, 2012 03:29 PM
What I tend to do is to remove mappings from the context and into commands.
you can then split you bootstrap into phases.
in the context inject your AppUitls ( which shall we say dispatched a COMPLETE event )
then map your Mapping commands to fire on AppUitlsCompleteEvent.COMPLETE.
being me, I also tend to hook all this into an FSM that manages progression through the Bootstrap sequence, so you can sequence your dependencies nicely.
3 Posted by pingale.indrajit on 02 Jun, 2012 05:32 PM
Thanks Neil. You are right. This is the only solution for my problem.
Thanks again.
pingale.indrajit closed this discussion on 02 Jun, 2012 05:32 PM.