-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
60 lines (45 loc) · 1.44 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!doctype html>
<html lang="en">
<script src="am.emmiter.js"></script>
<script>
//Usage
//Create Instance
var eventEmitter = new amEventEmitter();
//Quick Example
eventEmitter.register('event1', function(){
console.log('Event1 emitted');
});
eventEmitter.emit('event1');
//Passing data Example
eventEmitter.register('event2', function(data){
console.log('event2 emitted with data',data);
});
eventEmitter.emit('event2',{'name' : 'Jhon Potter'});
//Multiple register to same event
eventEmitter.register('event3', function(data){
console.log('event3 emitted!! first register',data);
});
eventEmitter.register('event3', function(data){
console.log('event3 emitted!! second register',data);
});
eventEmitter.emit('event3',{'name' : 'Jhon Potter'});
//Singal event emitting multiple times with different data
eventEmitter.register('event4', function(data){
console.log('event4 emitted!! ',data);
});
eventEmitter.emit('event4',{'name' : 'Jhon Potter'});
eventEmitter.emit('event4',{'name' : 'Harry Potter'});
//Mutting & UnMutting event
eventEmitter.register('event5', function(data){
console.log('event5 emitted!! ',data);
});
eventEmitter.emit('event5',{'name' : 'Jhon Potter'});
eventEmitter.mute('event5');
eventEmitter.emit('event5',{'name' : 'Harry Potter'});
eventEmitter.unmute('event5');
eventEmitter.emit('event5',{'name' : 'Mark welson'});
</script>
<body>
<h1>Open Console to see out put</h1>
</body>
</html>