+1
Answered

sync tag around play tag and subsequent if tag

sstava 12 ár síðan updated by icahill (Administrator) 12 ár síðan 3
I am extracting my parse.com error code management to a centralized action.

To make this work, I set a globalParseError-Code variable to the return "code" from parse.com

I then call an action that uses that global parse code to check against many if tags to see which if tag the error code matches.

In the global action, when it finds a match, it assigns an error title and message to respective global variables and also assigns a value to a globalParseError-ErrorExits variable of "true" to allow the original calling action to check to see if an error exists and take the appropriate action based on the activity of the original calling action (i.e. alert tag, clear fields, etc)

The activities that are after the "play" of the global error management routine occur before the centralized global error management routine returns :(

I was able to see this based on the order of the debug alerts that I setup and the fact that the error title, message and errorexists variables were not set

As a note, the content of the calling action is wrapped in a sync tag. The thought was that the sync tag would prevent the code after the play(centralized error mgt action) from executing before the play action was finished...this doesn't seem to be the case.

Does the sync tag wait for the return of a play action?

Thanks,
Steve
Unfortunately the sync tag will not wait for the play to finish its run. This is because once the play tag initiates another action block, the sync has no way of knowing how deep the play tag could go. The play tag could trigger another action through an additional play tag and etc.

Sync will only track the trigger of a play action and then move to the next action tag in the sync.
Thanks for the quick response!

Based on how play tags work, I decided to break the calling action into two actions. The first action ends after the play is called to the global error routine. I have a block variable specified on the calling play (_nextAction) that specifies the next action to play.

After the error routine has processed the error code, the last step is to play the passed in _nextAction.

This creates the same effect as a play being synchronous.

To get even better encapsulation and reuse abilities for the error mgt routine, would it be possible to get the synchronous effect by putting the error checking code in a separate wire and load it to start the error check and call-back to continue? (being lazy and asking before I spend some time on calling wires :) )

Thanks!
Steve
This could work, but you might see a time delay as the subwire loads and unloads. Also you would need to make sure all your variables were reassigned inside the subwire or they would get carried over.