[Project_owners] Global listeer

joe ertaba belaviyo at gmail.com
Tue Nov 20 22:38:41 PST 2007


As in :
          http://developer.mozilla.org/en/docs/wrappedJSObject,
when i use this code:
          http://forums.mozillazine.org/viewtopic.php?p=1694347#1694347

var myService =  Components.classes["@mozilla.doslash.org/test/component;1
"].getService();
myService.QueryInterface(Components.interfaces.*nsIObserver*);
dump(myService.observe)

it works perfectly and output is "function observe() { [native code] }"

but when i add some variable to code like:

MyComponent.prototype = {
...
MyVar:'hello',
....
}

then when i use above code again it works but the below code does not work

dump(myService.MyVar)  >>  undefined

maybe this problem cause because *nsIObserver ?*




On Nov 20, 2007 7:54 PM, Eric H. Jung <eric.jung at yahoo.com> wrote:

>
> --- joe ertaba <belaviyo at gmail.com> wrote:
> > in
> >
> > MyComponent.prototype = {
> > ...
> > MyVar:'hello',
> > ....
> > }
> >
> > how can access it from my extension
> > i want to write/read it as a global variable
>
> Use the wrappedJS trick (search MDC for info). You'll be able to do this
> from your extension:
>
> var myService = Component.classes["@joeertaba.org/myext/service;1
> "].getService().wrappedJSObject;
> myService.hello = "world!";
>
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> https://www.mozdev.org/mailman/listinfo/project_owners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.mozdev.org/pipermail/project_owners/attachments/20071121/94eb8750/attachment.html 


More information about the Project_owners mailing list