[TW5] Is the ordering of ActionSendMessageWidgets guaranteed?

43 views
Skip to first unread message

Antaeus Feldspar

unread,
Oct 18, 2015, 5:20:00 PM10/18/15
to TiddlyWiki
If I have two ActionSendMessageWidgets within a ButtonWidget, is the first one guaranteed to execute, and finish executing, before the second begins?

I ask because there are a TREMENDOUS number of things I'm wanting to do with TW5 which seem like they can be done very easily if serial execution is assured, and which are frustratingly difficult if not.

Jed Carty

unread,
Oct 18, 2015, 6:01:21 PM10/18/15
to TiddlyWiki
Yes, but there are some weird bits that come with the order that other things are done that may make it seem otherwise. For example, if you have something like this:

<$fieldmangler>
<$set name=SomeVariable value={{ThisTiddler!!tags}}>
<$button>BUTTON!!
<$action-sendmessage $message='tm-add-tag' $param=SomeTag/>
<$action-setfield $field='some_field' $value=<<SomeVariable>>/>
</$button>
</$set>
</$fieldmangler>

than the variable SomeVariable won't be updated with the value SomeTag when the field some_field is set. This is because of how widgets refresh.

So the order of the actions is sequential, but updating variables and other widgets may not take effect when you expect them to.

Matabele

unread,
Oct 19, 2015, 12:22:35 AM10/19/15
to TiddlyWiki
Hi

Although execution order of the action widgets themselves are serial, the order in which execution finishes in the listening widgets are not necessarily (in practice, the order of execution is most often serial.)

In critical situations, the listening widget could trigger a message at the end of execution (tm-finished), and a listener for this message could be added to the original dispatching widget before the 'return true;' statement (thus delaying execution of the next action widget.)

regards

PMario

unread,
Oct 19, 2015, 4:22:32 AM10/19/15
to TiddlyWiki
I wouldn't rely on the execution order to be serial. TW uses several caches and queues. eg: lazy loading of tiddler content, if used with a server side backend.
Also animations could / may queue up other actions. You can dig into the core code and see, where and how the nextTick() function is used.

Also many parts of TW have to work in the browser and with nodejs from the command line. nodejs is a highly asynchronous framework and so is the web and TW. see ajax.

have fun!
mario
Reply all
Reply to author
Forward
0 new messages