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

From MozillaWiki
< Labs‎ | Jetpack‎ | Reboot‎ | JEP
Jump to navigation Jump to search
No edit summary
Line 23: Line 23:
me = require("me");
me = require("me");


me.onFirstRun( function )
// eventName is one of install, uninstall
me.bind(eventName, callback);
 
 
// These are potential convenience functions
me.onInstall( function )
me.onInstall( function )
me.onUninstall( function )
me.onUninstall( function )
</pre>
</pre>


The <code>me.onFirstRun</code> gets called on the first run of an extension. If an extension is uninstalled and reinstalled (and the original data wasn't removed via a purge event) then the callback(s) passed to <code>onFirstRun</code> aren't called.
The <code>me.onInstall</code> gets called on the first run of an extension. If an extension is uninstalled and reinstalled it gets called again (as the act of uninstalling removes all data associated with the add-on).
 
The rest of the event handlers should be self-explanatory.


Because Jetpacks are easily installed and uninstalled, the concepts of disabling/enabling an extension have been removed.
There does not seem to be a strong use-case for allowing for event handlers that act upon disabling and enabling an extension.


==== Declarative ====
==== Declarative ====
Line 40: Line 42:
<pre class="brush:js;">
<pre class="brush:js;">
manifest = {
manifest = {
   firstRunPage: stringOrXml,
   installPage: stringOrXml,
   uninstallPage: stringOrXml
   uninstallPage: stringOrXml
}
}
Line 61: Line 63:
* What methods, mechanisms, or resources does this provide internally within the Jetpack platform code.
* What methods, mechanisms, or resources does this provide internally within the Jetpack platform code.


=== Use Cases ===


=== Minimum Base API Methods ===
* Show a welcome page/tutorial when you install an add-on.
 
* Show a set of tooltips for the UI that an extension has added, in vivo to the interface.
<pre class="brush:js">
* Give a survey when you uninstall an add-on.
me = require("me");
me.onInstall(function);
me.onUninstall(function);
</pre>
 
Everything else is sugar.

Revision as of 22:23, 11 February 2010

JEP 105 - Life-cycle

  • Champion: Aza Raskin - aza@mozilla.com
  • Status: Accepted/In-Queue
  • Bug Ticket:
  • Type: API
  • Difficulty: 4


Proposal

This JEP describes an API for handling the life-cycle of Jetpacks. In particular, it gives a Jetpack methods for registering event handlers for various install and uninstall states.

In addition to the event handlers, it provides a more declarative format.

Events

All methods of an add-on introspecting and interacting with its environmental metas using the Jetpack API live in the "me" module.

The event handlers can be used as follows:

me = require("me");

// eventName is one of install, uninstall
me.bind(eventName, callback);


// These are potential convenience functions
me.onInstall( function )
me.onUninstall( function )

The me.onInstall gets called on the first run of an extension. If an extension is uninstalled and reinstalled it gets called again (as the act of uninstalling removes all data associated with the add-on).

There does not seem to be a strong use-case for allowing for event handlers that act upon disabling and enabling an extension.

Declarative

The first-run experience is coded inside of manifest.json, the feature's manifest, which is (not un-coincidentally) where the settings are placed.

manifest = {
  installPage: stringOrXml,
  uninstallPage: stringOrXml
}

Difficulty

Rating: Easy

Key Issues

  • enable/disable?
  • when is it run?

Dependencies & Requirements

  • Dependent on JEP 106


Internal Methods

  • What methods, mechanisms, or resources does this provide internally within the Jetpack platform code.

Use Cases

  • Show a welcome page/tutorial when you install an add-on.
  • Show a set of tooltips for the UI that an extension has added, in vivo to the interface.
  • Give a survey when you uninstall an add-on.