Triggering an action on appear / when rendered

Is there any way to run actions when a tiddler is rendered or on appear?

For instance:

  • load the weather when “Weather Dashboard” is loaded
  • hit a web server to render the contents of a custom widget

I have used <$action-timeout> before, and startup actions, but these require more scaffolding. For instance, the weather example needs to hit the network periodically to get up to date information.

You can try my trigger-plugin – You need to make a backup first

It is possible to brick your wiki, if eg: tiddler A triggers tiddler B - which triggers tiddler A … and so on.
That’s the main reason, why a trigger-action is a plugin and not part of the core.

The plugin is listed as experimental, but it works fine since several TW versions, without any change.

The plugin enables a trigger-widget, with an actions parameter. You need to use the test tiddlers to see what’s going on. There is no documentation other than the example tiddlers at the moment.

have fun!
Mario

Thanks pmario - this is great.

I’m curious if someone could implement a cycle detector to avoid this “bricking” a wiki, but maybe that’s easier said than done.

It is not easy to detect or to avoid, because the flow is perfectly valid.

You have to carefully design your actions. It is easy to avoid endless loops, if done right.

I do have to mention it, because if used in the wrong way, it is possible to loose data.

Hi @Peter there is a new “background actions” feature that is being developed as part of a PR whose primary purpose is to make improvements to TiddlyWiki’s palette handling:

With background actions one can arrange an action to be performed whenever the result of evaluating a filter changes. A filter like [list[$:/StoryList]contains<mytiddler>] can be used to detect a particular tiddler being added to the story river.

4 Likes

Hey Jeremy - this looks like an awesome feature. I’m hoping for these to be merged into the core soon so I can adopt them in my wikis.

This seems flexible and like it could extend to the use cases (loading things when a tiddler enters the story, widgets that load content from the web) I mentioned.