~yolanda.robla/ubuntu/trusty/nodejs/add_distribution

« back to all changes in this revision

Viewing changes to doc/api/api/events.json

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{
2
 
  "source": "doc/api/events.markdown",
3
 
  "modules": [
4
 
    {
5
 
      "textRaw": "Events",
6
 
      "name": "Events",
7
 
      "stability": 4,
8
 
      "stabilityText": "API Frozen",
9
 
      "type": "module",
10
 
      "desc": "<p>Many objects in Node emit events: a <code>net.Server</code> emits an event each time\na peer connects to it, a <code>fs.readStream</code> emits an event when the file is\nopened. All objects which emit events are instances of <code>events.EventEmitter</code>.\nYou can access this module by doing: <code>require(&quot;events&quot;);</code>\n\n</p>\n<p>Typically, event names are represented by a camel-cased string, however,\nthere aren&apos;t any strict restrictions on that, as any string will be accepted.\n\n</p>\n<p>Functions can then be attached to objects, to be executed when an event\nis emitted. These functions are called <em>listeners</em>.\n\n\n</p>\n",
11
 
      "classes": [
12
 
        {
13
 
          "textRaw": "Class: events.EventEmitter",
14
 
          "type": "class",
15
 
          "name": "events.EventEmitter",
16
 
          "desc": "<p>To access the EventEmitter class, <code>require(&apos;events&apos;).EventEmitter</code>.\n\n</p>\n<p>When an <code>EventEmitter</code> instance experiences an error, the typical action is\nto emit an <code>&apos;error&apos;</code> event.  Error events are treated as a special case in node.\nIf there is no listener for it, then the default action is to print a stack\ntrace and exit the program.\n\n</p>\n<p>All EventEmitters emit the event <code>&apos;newListener&apos;</code> when new listeners are\nadded.\n\n</p>\n",
17
 
          "methods": [
18
 
            {
19
 
              "textRaw": "emitter.addListener(event, listener)",
20
 
              "type": "method",
21
 
              "name": "addListener",
22
 
              "desc": "<p>Adds a listener to the end of the listeners array for the specified event.\n\n</p>\n<pre><code>server.on(&apos;connection&apos;, function (stream) {\n  console.log(&apos;someone connected!&apos;);\n});</code></pre>\n",
23
 
              "signatures": [
24
 
                {
25
 
                  "params": [
26
 
                    {
27
 
                      "name": "event"
28
 
                    },
29
 
                    {
30
 
                      "name": "listener"
31
 
                    }
32
 
                  ]
33
 
                },
34
 
                {
35
 
                  "params": [
36
 
                    {
37
 
                      "name": "event"
38
 
                    },
39
 
                    {
40
 
                      "name": "listener"
41
 
                    }
42
 
                  ]
43
 
                }
44
 
              ]
45
 
            },
46
 
            {
47
 
              "textRaw": "emitter.on(event, listener)",
48
 
              "type": "method",
49
 
              "name": "on",
50
 
              "desc": "<p>Adds a listener to the end of the listeners array for the specified event.\n\n</p>\n<pre><code>server.on(&apos;connection&apos;, function (stream) {\n  console.log(&apos;someone connected!&apos;);\n});</code></pre>\n",
51
 
              "signatures": [
52
 
                {
53
 
                  "params": [
54
 
                    {
55
 
                      "name": "event"
56
 
                    },
57
 
                    {
58
 
                      "name": "listener"
59
 
                    }
60
 
                  ]
61
 
                }
62
 
              ]
63
 
            },
64
 
            {
65
 
              "textRaw": "emitter.once(event, listener)",
66
 
              "type": "method",
67
 
              "name": "once",
68
 
              "desc": "<p>Adds a <strong>one time</strong> listener for the event. This listener is\ninvoked only the next time the event is fired, after which\nit is removed.\n\n</p>\n<pre><code>server.once(&apos;connection&apos;, function (stream) {\n  console.log(&apos;Ah, we have our first user!&apos;);\n});</code></pre>\n",
69
 
              "signatures": [
70
 
                {
71
 
                  "params": [
72
 
                    {
73
 
                      "name": "event"
74
 
                    },
75
 
                    {
76
 
                      "name": "listener"
77
 
                    }
78
 
                  ]
79
 
                }
80
 
              ]
81
 
            },
82
 
            {
83
 
              "textRaw": "emitter.removeListener(event, listener)",
84
 
              "type": "method",
85
 
              "name": "removeListener",
86
 
              "desc": "<p>Remove a listener from the listener array for the specified event.\n<strong>Caution</strong>: changes array indices in the listener array behind the listener.\n\n</p>\n<pre><code>var callback = function(stream) {\n  console.log(&apos;someone connected!&apos;);\n};\nserver.on(&apos;connection&apos;, callback);\n// ...\nserver.removeListener(&apos;connection&apos;, callback);</code></pre>\n",
87
 
              "signatures": [
88
 
                {
89
 
                  "params": [
90
 
                    {
91
 
                      "name": "event"
92
 
                    },
93
 
                    {
94
 
                      "name": "listener"
95
 
                    }
96
 
                  ]
97
 
                }
98
 
              ]
99
 
            },
100
 
            {
101
 
              "textRaw": "emitter.removeAllListeners([event])",
102
 
              "type": "method",
103
 
              "name": "removeAllListeners",
104
 
              "desc": "<p>Removes all listeners, or those of the specified event.\n\n\n</p>\n",
105
 
              "signatures": [
106
 
                {
107
 
                  "params": [
108
 
                    {
109
 
                      "name": "event",
110
 
                      "optional": true
111
 
                    }
112
 
                  ]
113
 
                }
114
 
              ]
115
 
            },
116
 
            {
117
 
              "textRaw": "emitter.setMaxListeners(n)",
118
 
              "type": "method",
119
 
              "name": "setMaxListeners",
120
 
              "desc": "<p>By default EventEmitters will print a warning if more than 10 listeners are\nadded for a particular event. This is a useful default which helps finding memory leaks.\nObviously not all Emitters should be limited to 10. This function allows\nthat to be increased. Set to zero for unlimited.\n\n\n</p>\n",
121
 
              "signatures": [
122
 
                {
123
 
                  "params": [
124
 
                    {
125
 
                      "name": "n"
126
 
                    }
127
 
                  ]
128
 
                }
129
 
              ]
130
 
            },
131
 
            {
132
 
              "textRaw": "emitter.listeners(event)",
133
 
              "type": "method",
134
 
              "name": "listeners",
135
 
              "desc": "<p>Returns an array of listeners for the specified event. This array can be\nmanipulated, e.g. to remove listeners.\n\n</p>\n<pre><code>server.on(&apos;connection&apos;, function (stream) {\n  console.log(&apos;someone connected!&apos;);\n});\nconsole.log(util.inspect(server.listeners(&apos;connection&apos;))); // [ [Function] ]</code></pre>\n",
136
 
              "signatures": [
137
 
                {
138
 
                  "params": [
139
 
                    {
140
 
                      "name": "event"
141
 
                    }
142
 
                  ]
143
 
                }
144
 
              ]
145
 
            },
146
 
            {
147
 
              "textRaw": "emitter.emit(event, [arg1], [arg2], [...])",
148
 
              "type": "method",
149
 
              "name": "emit",
150
 
              "desc": "<p>Execute each of the listeners in order with the supplied arguments.\n\n</p>\n",
151
 
              "signatures": [
152
 
                {
153
 
                  "params": [
154
 
                    {
155
 
                      "name": "event"
156
 
                    },
157
 
                    {
158
 
                      "name": "arg1",
159
 
                      "optional": true
160
 
                    },
161
 
                    {
162
 
                      "name": "arg2",
163
 
                      "optional": true
164
 
                    },
165
 
                    {
166
 
                      "name": "...",
167
 
                      "optional": true
168
 
                    }
169
 
                  ]
170
 
                }
171
 
              ]
172
 
            }
173
 
          ],
174
 
          "events": [
175
 
            {
176
 
              "textRaw": "Event: 'newListener'",
177
 
              "type": "event",
178
 
              "name": "newListener",
179
 
              "params": [],
180
 
              "desc": "<p>This event is emitted any time someone adds a new listener.\n</p>\n"
181
 
            }
182
 
          ]
183
 
        }
184
 
      ]
185
 
    }
186
 
  ]
187
 
}