@@ -7,39 +7,24 @@ annotator.registry package
7
7
8
8
`Registry ` is an application registry. It serves as a place to register and
9
9
find shared components in a running :class: `annotator.App `.
10
-
10
+
11
11
You won't usually create your own `Registry ` -- one will be created for you
12
- by the :class: `~annotator.App `. If you are writing an Annotator module, there
13
- are, broadly, two main scenarios in which you will need to interact with the
14
- registry.
15
-
16
- 1. If you are writing a module which overrides some default component, such
17
- as the "storage" component, you will use the registry in your module's
18
- `configure ` function to register your component::
19
-
20
- function myStorage () {
21
- return {
22
- configure: function (registry) {
23
- registry.registerUtility(this, 'storage');
24
- },
25
- ...
26
- };
27
- }
28
-
29
- 2. If your module needs to interact with some of the core components of the
30
- `App `, then you will find these exposed on the `Registry ` instance. For
31
- example, if your module needs to send a notification when the application
32
- starts, you can use the "notifier" component which is exposed as the
33
- ``notify() `` function on the registry::
34
-
35
- function myModule () {
36
- return {
37
- start: function (registry) {
38
- registry.notify("Hello, world!");
39
- },
40
- ...
41
- };
42
- }
12
+ by the :class: `~annotator.App `. If you are writing an Annotator module, you
13
+ can use the registry to provide or override a component of the Annotator
14
+ application.
15
+
16
+ For example, if you are writing a module that overrides the "storage"
17
+ component, you will use the registry in your module's `configure ` function to
18
+ register your component::
19
+
20
+ function myStorage () {
21
+ return {
22
+ configure: function (registry) {
23
+ registry.registerUtility(this, 'storage');
24
+ },
25
+ ...
26
+ };
27
+ }
43
28
44
29
45
30
.. function :: annotator.registry.Registry.prototype.registerUtility(component, iface)
0 commit comments