This is because the observer service implementation included with the
SDK only takes a function as a callback - this is different ( simpler?
) from how observers work in lower-level code. The documentation is
here:
https://addons.mozilla.org/en-US/developers/docs/sdk/1.8/packages/api-utils/observer-service.html
cheers, Jeff
On Fri, Jul 27, 2012 at 9:17 PM, Yansky . <
thego...@gmail.com> wrote:
> Hi, I seem to be encountering an error when I try to pass an object rather
> than a function callback to an observer. I'm not sure if it's a problem with
> my code or a bug with the SDK.
> My code:
>
> var observers = require("observer-service");
> var ob;
> exports.main = function() {
> ob = {
> observe:function(subject,data){
> console.log('document-element-inserted')
> }
> };
> observers.add('document-element-inserted', ob);
> };
> exports.onUnload = function (reason) {
> observers.remove('document-element-inserted', ob);
> };
>
> The error message I get is:
> error: An exception occurred.
> Traceback (most recent call last):
> File
> "resource://jid1-nmj9rnjh73jn8g-at-jetpack/api-utils/lib/system/events.js",
> line 58, in
> data: data
> File
> "resource://jid1-nmj9rnjh73jn8g-at-jetpack/api-utils/lib/observer-service.js",
> line 35, in listener
> callback.call(target || callback, subject, data);
> TypeError: callback.call is not a function
>
> I'm using version 1.8.1 of the SDK with Firefox Aurora 16.0a2 on OSX 10.7.4
>
> --
> You received this message because you are subscribed to the Google Groups
> "mozilla-labs-jetpack" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/mozilla-labs-jetpack/-/WgHOA-gEVHUJ.
> To post to this group, send email to
mozilla-la...@googlegroups.com.
> To unsubscribe from this group, send email to
>
mozilla-labs-jet...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/mozilla-labs-jetpack?hl=en.