Action widget lag

I’ve ran into a strange behavior on my recent project. Although I have a number of action widgets in a list, it seems like some might be starting before others are finished (they don’t run asynchronously do they?)

bullets-lag

tiddlers.json (4.4 KB)

I both hope that I’m missing something very simple, and yet not, as I’m an embarrassing number of hours into trying to figure this single issue!

If it’s not fully clear in the animation, the first time I click down it moves the “current” value, but you can’t see anything change. From then on, the screen acts one “turn” behind - which is shown as after a few “downs” I click an “up” but it still does one more down. At the end of the video I show clicking again on the “render” button, which is the same code that runs at the end of the button operation actions too, so it shouldn’t change anything, which I show by clicking it twice…

The only key concept that comes to mind is when a button is used he contents of the widget are activated first then the actions in the actions= parameter.

5.2.0 mentions some changes in relations to this so the updated value becomes available to the button, otherwise it has the value when first rendered, not at click time.

I think your answer may lay somewhere in these issues.

1 Like

Aha! that was close enough @TW_Tones to help me find it explained in the documents (https://tiddlywiki.com/#ActionWidgets) in the section " Action Execution Modes".

The “magic” variable that you can set in 5.2 to fix this is tv-action-refresh-policy which needs to be set to always though apparently not globally, so need to wrap each actions macro with the variable set via set/vars I guess.

Well at least it wasn’t something very obvious, thanks again for the assist @TW_Tones

2 Likes

The underlying issue is that action widgets are not always refreshed, so they do not pick up values changed by previous widgets in the same block. Having to work around this has always been the greatest challenge with writing complex sequences of action widgets.

Note that using tv-action-refresh-policy within the body of a triggering widget (such as Button) might be problematic as the entire contents of the widget will be refreshed during the execution. Using the actions attribute to specify the actions to be invoked is the recommended way to use this variable.