Skip to content

Commit 49ff46f

Browse files
committed
Update index.md
1 parent 1f8c2e1 commit 49ff46f

File tree

1 file changed

+1
-55
lines changed

1 file changed

+1
-55
lines changed

index.md

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -35,61 +35,7 @@ EventEmitter is at the core of Node asynchronous event-driven architecture. Many
3535
* Emitting name events.
3636
* Registering and unregistering listener functions.
3737

38-
**Example 01:** Create an event emitter instance and register a couple of callbacks
39-
40-
```js
41-
/**
42-
* Callbacks Events
43-
*/
44-
const events = require('events');
45-
const eventEmitter = new events.EventEmitter();
46-
47-
function listenerOne() {
48-
console.log('First Listener Executed');
49-
}
50-
51-
function listenerTwo() {
52-
console.log('Second Listener Executed');
53-
}
54-
55-
eventEmitter.on('listenerOne', listenerOne); // Register for listenerOne
56-
eventEmitter.on('listenerOne', listenerTwo); // Register for listenerOne
57-
58-
// When the event "listenerOne" is emitted, both the above callbacks should be invoked.
59-
eventEmitter.emit('listenerOne');
60-
```
61-
62-
**Output:**
63-
64-
```js
65-
First Listener Executed
66-
Second Listener Executed
67-
```
68-
69-
**Example 02:** Registering for the event to be fired only one time using **once**.
70-
71-
```js
72-
/**
73-
* Emit Events Once
74-
*/
75-
const events = require('events');
76-
const eventEmitter = new events.EventEmitter();
77-
78-
function listenerOnce() {
79-
console.log('listenerOnce fired once');
80-
}
81-
82-
eventEmitter.once('listenerOne', listenerOnce); // Register listenerOnce
83-
eventEmitter.emit('listenerOne');
84-
```
85-
86-
**Output:**
87-
88-
```js
89-
listenerOnce fired once
90-
```
91-
92-
**Example 03:** Registering for the event with callback parameters
38+
**Example:** Registering for the event with callback parameters
9339

9440
```js
9541
/**

0 commit comments

Comments
 (0)