What is the difference of $tw.wiki.addEventListener and $tw.rootWidget.addEventListener

Good question - On the js level you can’t. But …

The point is, that hooks are only implemented if there is a strong demand for a TW plugin or for a 3rd party plugin, where the author can proof that, it absolutely is necessary.

We are pretty certain, that the existing hooks are used “in the wild”. Otherwise we would have a lot of hooks that are never used, but we still need to make sure that they are maintained.

Hooks are for JavaScript developers. So they are only usable by a fraction of a fraction of our user-base.

So it would be much better to allow users to react on certain states of the UI with wikitext, which covers 100% of our user-base.

There are only 2 places in the TW UI that emit tm-close-all-tiddlers

Both of them are short, in terms of lines of code (loc). So it will be much easier to modify them, if you really have to.

If you create a new custom button, you already have control of the flow. So no core help needed.


For some users it may be confusing if they do not see anything after they closed all tiddlers. There are 2 options to show something if the story-river is empty.

  1. Hidden Setting: Content to be displayed for empty story
  2. The new since v5.4.0 Background Actions

Add 1)

  • Create a tiddler: $:/config/EmptyStoryMessage
  • With content: {{HelloThere||$:/core/ui/ViewTemplate}}

And you are done. Instead of HelloThere you can use a Dashboard or a giant Home-Button … Whatever you want. The advantage is no JS needed - 100% user base covered.

Add 2)

Background action is a core function that evaluate a filter, that allows users to react on certain wiki states. eg: Story river is empty.

The story river is sensitive to changes of the list-field in the $:/StroyList tiddler. If the list-field is empty, the action may do something.

title: test-empty-story-background-action
track-filter: [list[$:/StoryList]count[]match[0]]
text: <$action-sendmessage $message="tm-home" />

This may be a bit strange, but it depends. The important thing is the user has the choice

100% user base covered.


Background actions are new since v5.4.0 - They are incredibly powerful, because they can track the wiki state.

Since TW is 100% state driven, you can reach every UI state you want using wikitext only. This should significantly reduce the need for new hooks.

Have fun!
Mario

1 Like