667
edits
Changes
→Adding our own code
this.initialized = true;
this.firstxpcom = Components.classes["@senecac.on.ca/firstxpcom;1"]
this.firstxpcom.name = "First XPCOM";
// Use the Alerts Service to display the results to the user.
var alertsService = Components.classes["@mozilla.org/alerts-service;1"]
alertsService.showAlertNotification(null, this.firstxpcom.name, this.total,
false, "", null);
this.firstxpcom = Components.classes["@senecac.on.ca/firstxpcom;1"]
var alertsService = Components.classes["@mozilla.org/alerts-service;1"]
In the former case we use '''createInstance''', which gives us a new unique instance. In the latter, we use '''getService''', which returns a shared instance of an existing component (i.e., a Singleton). Unlike IFirstXpcom, which can be created many times by different callers, the nsIAlertsService is a shared component, because only one pop-up message at a time can be shown to the user.