Labs/JS Modules: Difference between revisions

try a flatter structure
(add the Observers module)
(try a flatter structure)
Line 1: Line 1:
Back to [[Labs]].
Back to [[Labs]].
= JavaScript Modules =


Here you'll find a collection of modules which you can import into your extension.  The goal is to make extension development easier by implementing common functionality as reusable libraries.
Here you'll find a collection of modules which you can import into your extension.  The goal is to make extension development easier by implementing common functionality as reusable libraries.
Line 12: Line 10:
If you would like to contribute a new module, get in touch with us at #labs!
If you would like to contribute a new module, get in touch with us at #labs!


== Logging ==
= Logging =


This is a partial implementation of the Log4* interfaces (for example, see [http://logging.apache.org/log4j/1.2/index.html log4j] or [http://logging.apache.org/log4net/ log4net]).  The original implementation came from Michael Johnston, but it was heavily modified by Dan Mills to get it into Weave.
This is a partial implementation of the Log4* interfaces (for example, see [http://logging.apache.org/log4j/1.2/index.html log4j] or [http://logging.apache.org/log4net/ log4net]).  The original implementation came from Michael Johnston, but it was heavily modified by Dan Mills to get it into Weave.
Line 58: Line 56:
* [http://hg.mozilla.org/labs/weave/index.cgi/raw-file/8e3d60172f32/modules/log4moz.js log4moz.js] - Raw (right-click to save)
* [http://hg.mozilla.org/labs/weave/index.cgi/raw-file/8e3d60172f32/modules/log4moz.js log4moz.js] - Raw (right-click to save)


== Observers ==
= Observers =


The [http://melez.com/mozilla/modules/Observers.js Observers module] provides an API for observing and sending notifications using the [http://mxr.mozilla.org/mozilla/source/xpcom/ds/nsIObserverService.idl observer service].
The [http://melez.com/mozilla/modules/Observers.js Observers module] provides an API for observing and sending notifications using the [http://mxr.mozilla.org/mozilla/source/xpcom/ds/nsIObserverService.idl observer service].
Line 75: Line 73:
Note: you can use this module to observe notifications generated by any XPCOM component, and you can send notifications whose subject is an XPCOM component, but only JavaScript consumers of this API can send and receive notifications whose subject is an arbitrary JavaScript object.
Note: you can use this module to observe notifications generated by any XPCOM component, and you can send notifications whose subject is an XPCOM component, but only JavaScript consumers of this API can send and receive notifications whose subject is an arbitrary JavaScript object.


== Preferences ==
= Preferences =


The [http://melez.com/mozilla/modules/Preferences.js Preferences module] provides an API for accessing application preferences.  Getting and setting prefs is easy:
The [http://melez.com/mozilla/modules/Preferences.js Preferences module] provides an API for accessing application preferences.  Getting and setting prefs is easy:
canmove, Confirmed users
2,056

edits