Hi Tobias,
воскресенье, 3 марта 2013 г., 16:49:01 UTC+4 пользователь Tobias Beer написал:
Hi Mario,
So, doing that, the actual macro magic is deferred to a refresh method first invoked when the macro is called.
What (mechanism) exactly triggers a refresh in this case?
I mean, do these DOM attributes simply mean "Dear TiddlyWiki, whenever you refresh (anything), please rerun the macro referenced via these attributes with these params." ...which then fires the macro handler again?
But then, why is the refresh handler given a list - one which has not existed before the macro handler was called?
Not sure what do you mean, but probably this will help:
* on wikification, .handler is called
* .handler calls the .refresh and .refresh is called by config.refreshers.macro (usual refreshing mechanism)
* .handler creates the list element and .refresh refreshs its content
* config.refreshers are used by the refreshElements function which, in turn, is used by refreshPageTemplate and refreshDisplay (and config.refreshers.tiddler), which, in turn, are called by refreshAll and are present in config.notifyTiddlers
* all functions of config.notifyTiddlers are added to store via store.addNotification on startup, those and others store.namedNotifications are called by store.notify and store.nofityAll which, in turn, is called by
** store.removeTiddler
** store.resetTiddler
** store.setTiddlerTag
** store.addTiddlerFields
** store.saveTiddler
** store.setValue
which means that the .refresh methods of macros are called at least each time[*] one of these 6 methods is used which should be enough.
So, to make any macro refreshable, just use .refresh method. Likewise, tiddler are refreshed on those store methods' calls as config.notifyTiddlers contain refreshDisplay as well.
To investigate this further, you can take a look at Refresh.js [1] and TiddlyWiki.js [2], but some things are more useful to search right in a TiddlyWiki code (I open
tiddlywiki.com for that sometimes).
Is a macro refresh handler always passed the DOM element from which it was fired? In other words, are these attributes somewhat markers that indicate "this output (wrapper) has been contructed by macro xyz"? If yes, would it be best practice to always add this stuff to a macro that renders something?
Cheers, Tobias.
Best regards,
Yakov.
[*] I may be wrong here as when I quickly looked up I haven't studied the conditionals carefully