DoclerLabs / hexMachina

Releases, issues, documentation, website of hexMachina, framework written in Haxe
http://hexmachina.org
MIT License
44 stars 8 forks source link

"Safe state" for runtime assembling #179

Closed aismagulov closed 7 years ago

aismagulov commented 7 years ago

I have two DSL files for the same application context. I want to assemble them one after another and run some initialization macro for each one. Everything happens in runtiime.

So in file1.xml I have this:

<state id="onFileOneAssembled" ref="armageddon-client.state.ASSEMBLING_END">
    <enter command-class="FirstInitializationMacro" fire-once="true"/>
</state>

FirstInitializationMacro is synchronous, and at the end of its job it runs assemblng of second DSL file, which also has:

<state id="onFileTwoAssembled" ref="armageddon-client.state.ASSEMBLING_END">
    <enter command-class="SecondInitializationMacro" fire-once="true"/>
</state>

So here is the problem. When FirstInitializationMacro is started, application is still in transition to ASSEMBLING_END state. When second file is assembled, application is still in the same transition between states. So no other transition can happen while assembling second file, second ASSEMBLING_END won't start new transition, and SecondInitializationMacro never starts.

I would like to have a separate state machine event, that shows that all transitions are finished, and I can safely start assembling second file.

FrancisBourre commented 7 years ago

For now, we added ApplicationAssemblerMessage.IDLE_MODE By the way, you need to target it by code. It's not accessible from DSL for now.