summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorportix <none@none>2012-10-31 22:07:30 +0100
committerportix <none@none>2012-10-31 22:07:30 +0100
commit6c878b9886479e70959ca82d84a627c838588ff4 (patch)
tree066bc09a6027b0decad3b56bcf3842e74b92bb82 /api
parent213da4fc0ad5b694c6db07249d5378b298318833 (diff)
downloaddwb-6c878b9886479e70959ca82d84a627c838588ff4.zip
Return all modules if array is null in require
Diffstat (limited to 'api')
-rw-r--r--api/dwb-js.727
-rw-r--r--api/jsapi.7.txt22
-rw-r--r--api/jsapi.txt22
3 files changed, 59 insertions, 12 deletions
diff --git a/api/dwb-js.7 b/api/dwb-js.7
index 76a91025..585ef7ed 100644
--- a/api/dwb-js.7
+++ b/api/dwb-js.7
@@ -242,7 +242,9 @@ An array of module names
.PP
\fIcallback\fR
.RS 4
-A callback function that is called after initialization of all scripts and modules\&. The parameters of the callback function correspond to the names array, see MODULES for examples\&.
+A callback function that is called after initialization of all scripts and modules\&. The parameters of the callback function correspond to the names array\&. If
+names
+is null the function is called with one parameter that contains all modules, see also MODULES for examples\&.
.RE
.RE
.sp
@@ -2464,7 +2466,7 @@ For sharing data between scripts either signals or modules can be created\&.
.sp
With modules it is possible to share objects between scripts\&. Modules are defined with provide and loaded with require\&.
.PP
-\fBScript 1\fR.
+\fBDefining modules\fR.
.sp
.if n \{\
.RS 4
@@ -2488,7 +2490,7 @@ provide("myOtherModule", {
.RE
.\}
.PP
-\fBScript 2\fR.
+\fBGetting some modules\fR.
.sp
.if n \{\
.RS 4
@@ -2506,6 +2508,25 @@ require(["myModule", "myOtherModule"], function(myModule, myOtherModule) {
.if n \{\
.RE
.\}
+.PP
+\fBGetting all modules\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+#!javascript
+
+require(null, function(modules) {
+ if (modules\&.myModule\&.foo == 37)
+ modules\&.myModule\&.doBar();
+
+ modules\&.myOtherModule\&.act("foo");
+});
+.fi
+.if n \{\
+.RE
+.\}
.sp
.SH "EXTENSIONS"
.sp
diff --git a/api/jsapi.7.txt b/api/jsapi.7.txt
index fc00c05e..3ad27d95 100644
--- a/api/jsapi.7.txt
+++ b/api/jsapi.7.txt
@@ -124,7 +124,8 @@ Load modules defined with provide.
_names_;; An array of module names
_callback_;; A callback function that is called after initialization of all
scripts and modules. The parameters of the callback function correspond to the
-names array, see MODULES for examples.
+names array. If +names+ is null the function is called with one parameter that
+contains all modules, see also MODULES for examples.
****
@@ -1197,8 +1198,8 @@ For sharing data between scripts either signals or modules can be created.
With modules it is possible to share objects between scripts. Modules are
defined with +provide+ and loaded with +require+.
-.Script 1
-[source,javascript]
+
+.Defining modules
-------
#!javascript
@@ -1215,8 +1216,7 @@ provide("myOtherModule", {
});
-------
-.Script 2
-[source,javascript]
+.Getting some modules
-------
#!javascript
@@ -1228,6 +1228,18 @@ require(["myModule", "myOtherModule"], function(myModule, myOtherModule) {
});
-------
+.Getting all modules
+-------
+#!javascript
+
+require(null, function(modules) {
+ if (modules.myModule.foo == 37)
+ modules.myModule.doBar();
+
+ modules.myOtherModule.act("foo");
+});
+-------
+
== EXTENSIONS ==
*dwb* provides the possibility to load extensions.
It is recommended to implement javascript-userscripts as an extension to have
diff --git a/api/jsapi.txt b/api/jsapi.txt
index 3cf95d3c..7ae151a7 100644
--- a/api/jsapi.txt
+++ b/api/jsapi.txt
@@ -150,10 +150,11 @@ Load modules defined with <<provide>>.
::
-_names_;; An array of module names
+_names_;; An array of module names or null to get all modules.
_callback_;; A callback function that is called after initialization of all
scripts and modules. The parameters of the callback function correspond to the
-names array, see <<Modules>> for examples.
+names array. If +names+ is null the function is called with one parameter that
+contains all modules, see also <<Modules>> for examples.
****
****
@@ -2059,7 +2060,7 @@ For sharing data between scripts either signals or modules can be created.
With modules it is possible to share objects between scripts. Modules are
defined with +provide+ and loaded with +require+.
-.Script 1
+.Defining modules
[source,javascript]
-------
#!javascript
@@ -2077,7 +2078,7 @@ provide("myOtherModule", {
});
-------
-.Script 2
+.Getting some modules
[source,javascript]
-------
#!javascript
@@ -2090,6 +2091,19 @@ require(["myModule", "myOtherModule"], function(myModule, myOtherModule) {
});
-------
+.Getting all modules
+[source,javascript]
+-------
+#!javascript
+
+require(null, function(modules) {
+ if (modules.myModule.foo == 37)
+ modules.myModule.doBar();
+
+ modules.myOtherModule.act("foo");
+});
+-------
+
[[Extensions]]
== Extensions ==
*dwb* provides the possibility to load extensions.