Ticket #978 (assigned enhancement)

Opened 18 months ago

Last modified 8 months ago

Core TiddlyWiki operations should fire custom events

Reported by: PhilHawksworth Owned by: FND
Priority: major Milestone: 3.0
Component: core Version:
Severity: low Keywords: jQuery events hooks
Cc:

Description

jQuery supports the triggering and binding to custom events. It would be helpful if TiddlyWiki triggered custom events after performing some actions such as:

LoadingShadows? LoadingTiddlers? SavingTiddlers? OpeningTiddler?

etc.

Could we please begin with some custom events in the main() function? This also gives a good opportunity to refactor this function to remove the instrumentation into a function of its own.

I would suggest being able to bind to:

loadShadows loadTiddlers loadPlugins startup

Attachments

ticket978.patch Download (1.0 KB) - added by PhilHawksworth 18 months ago.
new custom events for main.js

Change History

Changed 18 months ago by PhilHawksworth

new custom events for main.js

Changed 18 months ago by MartinBudden

  • priority changed from undefined to minor
  • status changed from new to closed
  • resolution set to fixed

Fixed in changeset:9148

Changed 18 months ago by FND

cf. #484

Changed 18 months ago by SaqImtiaz

  • status changed from closed to reopened
  • resolution fixed deleted

I don't quite understand why this ticket has been closed as the custom events mentioned have not been implemented in their entirety nor the idea rejected. Note that Phil asked for certain events related to startup as a beginning and not as the only changes.

I too think it would be helpful if TiddlyWiki fired events after actions like saving tiddlers and opening tiddlers. It would be extremely helpful for plugin writers. Eg: a openedTiddler or refreshedTiddler event would be an elegant alternative to hijacks of story.refreshTiddler which are currently necessary in many plugins.

I'd like to suggest that we take the time to create a list of actions that should be triggering custom event so that we can add them methodically, something that will also lead to more consistent naming of the events. Note the "startup" event for instance seems like a misnomer, startup has already completed and restart is about to be called. It would be good to give some thought to event names and how they fit with existing TiddlyWiki terminology. Event names should be more explicit perhaps, eg: startupComplete

Furthermore, with regards to changeset:9149, have we considered how this impacts the paramifiers? Would we want to later refactor them to take advantage of the same triggers? We should try to consolidate these different hooks and triggers. Any changes to main() should also take into account the hooks requested in ticket 484 (including an event/hook for when restart is complete).

Changed 18 months ago by SaqImtiaz

Correction: the last paragraph in the comment above should refer to changeset:9148 and NOT 9149.

Changed 18 months ago by FND

  • keywords jQuery hooks added; jQuery, removed
  • priority changed from minor to major

After discussing this with Saq, a few more details:

Triggers are supposed to pinpoint a particular action having been completed by the core code, as opposed to a particular function having been executed.

This is an important distinction because hijacking functions is the norm in TiddlyWiki; in case of a hijack of a function related to a trigger, the trigger should only fire after the hijack too has been executed.

Therefore, wherever possible the triggers should be invoked before/after the respective functions performing the action.

Example:
An event after plugins have been loaded in main. However, this is easier in the case of loadPlugins, which is only ever called at a particular time, than for functions like story.refreshTiddler, which can be called from many different places. In situations such as the latter it may be necessary to have the trigger at the end of the function, e.g. a refreshedTiddler trigger at the end of refreshTiddler.

Changed 17 months ago by MartinBudden

  • milestone changed from 2.5.1 to 2.5.2

Changed 15 months ago by FND

cf. #1076

Changed 13 months ago by FND

  • milestone changed from 2.5.3 to 2.5.4

Changed 10 months ago by FND

  • owner changed from JeremyRuston to FND
  • status changed from reopened to new

Changed 10 months ago by FND

  • status changed from new to assigned

Changed 8 months ago by FND

  • milestone changed from 2.6 to 3.0
Note: See TracTickets for help on using tickets.