On 5/14/07, raven <[EMAIL PROTECTED]> wrote:
> Hi, I want to support asynchronous callbacks from my javascript code. The
> example below will clarify my point:
>
> //c is an instance of my component implemented in c++
> //using xpcom
> c = Components.classes["my comp id"].createInstance(...);
> //doSmthg takes an input variable and a callback
> c.doSmthg( my_variable, my_on_completion_callback )
> ...
> function my_on_completion_callback( ... )
> {
>     //handle completion
> }
>
> I asked some of the developers on the irc how to do this and they pointed
> out that I need to use nsIProxyManager. But unfortuantly i didn't find much
> links clarifying this subject, so I would be gratefull if anyone could
> elaborate an example of a simple implemetation.
> Thx in advance
>
Does your component do its work on a separate thread and needs to
invoke the callback from that worker thread? If so, you probably got
pointed to http://www.mozilla.org/projects/xpcom/Proxies.html

Otherwise, you don't need that and can invoke the callback directly.

Note that in any case, you should either pass an object implementing
certain interface to doSmthg or declare doSmthg's callback parameter
as a "[function]" interface, such as nsIDOMEventListener
(http://lxr.mozilla.org/mozilla/source/dom/public/idl/events/nsIDOMEventListener.idl)

Nickolay
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to