How to set the wait time

The documentation doesn’t seem to mention such a widget like waiting a few seconds before executing what comes after.

As well as whether it is possible to improve notify related functionality, including the ability to set the style, the time of the prompt, and the ability to click on a link in the text to jump to it if there is a link in the text.

Hi @dongrentianyu the core does not currently contain any primitives for scheduling tasks or timeouts. There is a PR underway which introduces a low level mechanism for background actions, including timeouts:

2 Likes

Keep in mind that such pauses stop tiddlywiki returning to render the whole wiki.

There are actions that one needs to delay or the next action can fail but it is best to design around this if possible, to keep the wiki interactive.

Danger

There is also a danger if a pause is inside a loop you may have only a 1 second delay but its repeated a 1000 times than you end up stuck with a 1000 second delay.

Interactive workaround

One manual work around is to use the ActionConfirmWidget to cause an interactive pause, but keep the above Danger note in mind.

Ultimatly it would be better if we could introduce a pause until a condition is met but that can be broken out of. Like the old Ctrl-C. However this may need to break out of both the pause and the loop responcible for activating the pause.

  • Consider a widget that would wrap a block of tiddlywiki script such that what ever happens inside the user can breakout of that and continue below. I know this is not strait forward.

Similarly what if some processes can be effectivly pushed into the background - multi-tasking in effect, allowing the wiki to return whilst that process continues. Then the ability to cancel such processes.

I have a button that functions to save the contents of a quick note and the value is stored in a status entry. If the status entry has no content, it displays notify as no note, if it has content, it displays note saved. After saving the note it empties the status entry above. But I’ve found that notify stays for a few seconds, so notify will show that the note is saved, and then it immediately changes to no note present. Because the status entry is immediately cleared, the content of the notify is immediately changed. But I don’t want to do that, because my note is indeed saved, I just need to clear the status entry to prepare for the next note.

Now my solution to deal with this is to make it two buttons so that there is no problem.

quick-note-button
<center>
<$button  style="width: 40%;">
<%if [{$:/state/self/quick-note}length[]compare:number:lteq[0]] %>
  <$action-sendmessage $message="tm-notify" $param="quick-note-notify" no-text="无笔记存在,不保存!!!"/>
<%else%>
  <$action-createtiddler 
  $basetitle=<<unusedtitle baseName:"quick-note" separator:"-">> 
  tags="quick-note-file" 
  text={{{ [[$:/state/self/quick-note]get[text]] }}}
  />
    <$action-sendmessage $message="tm-notify" $param="quick-note-notify" yes-text="笔记己保存!!!"/>
<%endif%>
Save
</$button>
<$button style="width: 40%;">
<$action-setfield $tiddler="$:/state/self/quick-note" text=""/>
Empty
</$button>
</center>
quick-note-notify
<%if [{$:/state/self/quick-note}length[]compare:number:lteq[0]] %>
<h1><<no-text>></h1>
<%else%>
<h1><<yes-text>></h1>
<%endif%>

So this could be a problem with notify. The solution I’ve come up with is to provide a countdown-like widget that clears the value of the status entry about three or five seconds after notify has finished displaying the content, so that maybe it won’t be a problem. But I don’t know enough about the underlying TiddlyWiki mechanics to be sure what that would bring.

You can use TiddlyTools/Time/action-timeout.js to invoke actions after a specified amount of time (in milliseconds).

For your use case, something like this might do:

<$action-timeout delay=5000
   actions='<$action-setfield $tiddler="$:/state/self/quick-note" text=""/>'/>

enjoy,
-e

1 Like

Thanks, that’s just what I needed.