Tiddlywiki lacks JS dev doc

I debug why an action widget will execute twice for a few hours (at night). Today when my brain is clearer, I look down the source code, and find an undocumented allowActionPropagation method does the trick.

The example

<$button>
  Click to receive <<count-gamification-reward>> rewards.

  <$let experienceSaveFile="experience">
    <$action-convert-game-event $eventTypes="SmallReward">
      <$action-createtiddler
        $basetitle=<<experienceSaveFile>>
        $overwrite="yes"
        text={{{ [<gameEvents>enlistJsonFilterTypeGetEvents[SmallReward]jsonget[amount]sum[]] =[<experienceSaveFile>get[text]else[0]] +[sum[]] }}}
      />
    </$action-convert-game-event>
  </$let>

</$button>

The action-createtiddler triggered twice, because button triggers it if I’m not using an undocumented allowActionPropagation method. And my custom widget $action-convert-game-event trigger it again.

So we really need a guide and full API doc for plugin developers. I think the https://tiddlywiki.com/dev/ is not enough, because it is manually maintained, is getting out of date because it doesn’t matter. We might need an auto-generated doc from the source code, that will block development if it doesn’t get updated, so people will going to update it.
And it is impossible to put all API to https://tiddlywiki.com/dev/ .

Did you try to move your action-widgets out into an actions procedure? And call it like so

It is a known issue, that actions inside buttons can misbehave.

<$button actions=<<gameActions>> ...>...

I just set up a new doc site

By reading modules_widgets.widget | Tiddlywiki JS Docs we can know adding this to the widget fixes my issue

  public allowActionPropagation() {
    return false;
  }

Docs are updated in GitHub - tiddly-gittly/TW5-Typed: TypeScript type definitions for TiddlyWiki5., basically updated when the TS developer is going to use an API and finds it is missing.

2 Likes