+1
Wird überprüft
Make 'play' have the option to be synchronous.
Calling 'play' causes the called action to execute asynchronously - i.e. the action that contains the play will carry on executing without waiting for the called action to complete.
This is a problem if you are creating a series of objects in a loop in response to a user action. You have no way of knowing when the loop completes.
So if the user action causes the current series of objects to be deleted and new ones created, and it is not possible to tell when the action has completed creating the new objects, the user could trigger the action again before it has completed - causing the objects to be deleted before they have finished being created - which causes the app to crash...
It would be really nice if the 'play' action had a flag to make it synchronous so that it could be used as a way of calling actions in the same way that developer created functions are used in any other language - i.e. reusable chunks of code which may change some global variable or passed in parameter and the calling function/action could then act on the modified variables.
This is a problem if you are creating a series of objects in a loop in response to a user action. You have no way of knowing when the loop completes.
So if the user action causes the current series of objects to be deleted and new ones created, and it is not possible to tell when the action has completed creating the new objects, the user could trigger the action again before it has completed - causing the objects to be deleted before they have finished being created - which causes the app to crash...
It would be really nice if the 'play' action had a flag to make it synchronous so that it could be used as a way of calling actions in the same way that developer created functions are used in any other language - i.e. reusable chunks of code which may change some global variable or passed in parameter and the calling function/action could then act on the modified variables.
Customer support service by UserEcho
Here is a admittedly very simple example.
<action name="test">
<sync loop="no" startdelay="0">
<alert message="test"/>
<alert message="test2"/>
</sync>
<play anim="action2" />
</action>
<action name="handle-user-action">
<if lhs="[var:busy-flag]" operator="eq" rhs="0">
<assign property="var:busy-flag" value="1">
<delete target="existing-panels">
<assign property="var:panel-count" value="0">
<play action="build-panels">
<assign property="var:busy-flag" value="0">
</if>
</action>
<action name="build-panels">
<if lhs="[var:panel-count]" operator="lt" rhs="[datasource:somedata.dataSourceResultCount]">
<sync>
<create class="panels" target="someparent" />
<play action="build-panels" />
</sync>
</if>
</action>
The busy flag gets cleared BEFORE the panels have finished being created. If the user triggers the action again before it completes, the app crashes because it is deleting objects that are still being created.
I might recommend a third action for your assign property="var:busy-flag" value="0" that is only triggered when your build panels action is successful.
Also the looping action 'build-panels' is not doing the creation directly but rather is alternately calling different actions which are doing the creation.
I would really like to clear the flag when creation is complete, which is pretty hard to do when calling a cascading series of actions.
I am sure there is a way to accomplish what you are requesting, have you tried adding a delay to your play tags? This should work as it extends <set>.