Skip to content

Instantly share code, notes, and snippets.

@ctkjose
Last active August 29, 2015 14:23
Show Gist options
  • Save ctkjose/2759204141a4db5d12f1 to your computer and use it in GitHub Desktop.
Save ctkjose/2759204141a4db5d12f1 to your computer and use it in GitHub Desktop.
KOMODO9 Observers Listen and Send

https://github.com/Komodo/KomodoEdit/wiki/138-events-and-notifications

var obsSvc = Components.classes['@mozilla.org/observer-service;1'].getService(Components.interfaces.nsIObserverService);
var listener = {
    observe: function(subject, topic, data) {
        alert("received observer subject: " + subject);
    }
};
obsSvc.addObserver(listener, "application-activated", false);
var obsSvc = Components.classes['@mozilla.org/observer-service;1'].getService(Components.interfaces.nsIObserverService);
obsSvc.notifyObservers(null, "my-topic", "some string data");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment