How should I read text at lazy loading

My Tiddlywiki 5.3.4 is configured using Node.js under windows. Lazy loading is enabled for a big data tiddler with type application/json.

Following documentation of lazy loading, I using function getTiddlerText to load text in my filter operator.

var t_text = $tw.wiki.getTiddlerText(title);

However, the text is not loaded and variable t_text equals to null.

After debugging, function exports.getTiddlerText in wiki.js is called with following codes

this.dispatchEvent("lazyLoad",title);
return null;

It seems system is loading text and return null. How should I wait for loading and get text?

After investigation of TW5 source codes, I figured out one way to implement how to read text for lazy load (might not be correct). I think it would be better to document in some places for developer.

For example, in view widget.

  • Variable this.viewTitle stores tiddler title for lazy loading.
  • In the function refresh, variable changedTiddlers store the updated list of tiddlers after event lazyload is triggered and text is updated.
  • Call this.refreshSelf() to re-render whole widget.

My example can be found here in my developing plugins.

Hi @Zheng_Bangyou filters in TiddlyWiki are synchronous and so it is not possible for a filter operator to wait for an asynchronous task to complete.

The lazy loading mechanism should result in a refresh being triggered when the payload of the tiddler is loaded. I suspect that the fundamental problem here is that the way you are displaying the tiddler does not get automatically refreshed. This could happen, for example, if the tiddler were processed by a JS macro because JS macros don’t support refreshes.

1 Like

Thanks for your explanation. Now I understand the mechanism of lazy loading and implemented refresh in my widget.