Labs/Jetpack/Reboot/JEP/105: Difference between revisions

Line 21: Line 21:


self.onUpgrade( function )
self.onUpgrade( function )
self.onEnable( function )
self.onDisable( function )


self.onUninstall( function )
self.onUninstall( function )
Line 35: Line 31:
The <code>onUninstall</code> handler is called when the add-on is uninstalled, giving add-ons the opportunity to clean up files, preferences, annotations <strike>or to flip the bird at the user on the way out</strike>.
The <code>onUninstall</code> handler is called when the add-on is uninstalled, giving add-ons the opportunity to clean up files, preferences, annotations <strike>or to flip the bird at the user on the way out</strike>.


Now that an add-on can be enabled and disabled without an application restart, add-ons should cleanly stop work (shut down page-workers, kill timers,
'''Enable/Disable'''
close streams) when they're disabled. They can do this via the <code>onDisable</code> handler. Conversely an add-on can kick it's services back into gear when it's enabled with the <code>onEnable</code> handler.
There's no need for explicit support for enabling and disabling of add-ons here. When an add-on is disabled, any callbacks the code registered with require("unload").when() or require("unload").ensure() are automatically called, and when an addon is enabled, its code is re-evaluated and its exports.main() is called.


=== Use Cases ===
=== Use Cases ===
Confirmed users, Bureaucrats and Sysops emeriti
2,088

edits