created: 20141122200310516 modified: 20141122200310516 title: Hook Mechanism type: text/vnd.tiddlywiki The Hook Mechanism provides a way for plugins to hook into and modify default functionality. Hooks can be added to the wiki by calling the following from a plugin: ``$tw.hooks.addHook(name,function definition);`` Multiple hooks can be appended to the same name using repeated calls to the above. When a hook is invoked by name all registered functions will be called seqentially in their order of addition. Though not essential care should be taken to ensure that hooks are added before they are invoked. For example: [[Hook: tc-opening-default-tiddlers-list]] should ideally be added before the story widget is invoked otherwise any hook specified additions to the default tiddlers will not be seen on the initial loading of the page, though will be visible if the user clicks the home button. !!Example A working example of addition to a hook that adds "test" to the default tiddlers. ```javascript $tw.hooks.addHook("th-opening-default-tiddlers-list",function(list) { list.push("test"); return list; }); ```