Thanks. I'll check this out. "Nickolay Ponomarev" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On 4/26/06, Susan Crayne <[EMAIL PROTECTED]> wrote: > Is this possible: > > 1. Javascript code registers a callback in an XPCOM > 2. Javascript code invokes a method in the XPCOM > 3. XPCOM code invokes an internal method and passes it some data > 4. Javascript callback function gets invoked with the data as a parameter > Yes, the easiest way to do callbacks to JS from native code is via XPCOM. Your callback code should be in a JS object implementing an interface appropriate for you (you can use an existing interface, such as nsIObserver or a custom interface).
I don't know of an example demonstrating this specific technique, but it's commonly used in the platform itself. The observer service is doing a similar thing, here's how to implement an nsIObserver in JS: http://kb.mozillazine.org/Using_observers and you can inspect the nsObserverService code to see how the C++ part works. Nickolay _______________________________________________ dev-tech-xpcom mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-xpcom
