Repository navigation
Expand file tree
/
Copy patheventbus.html
More file actions
executable file
·51 lines (43 loc) · 1.64 KB
/
Copy patheventbus.html
File metadata and controls
executable file
·51 lines (43 loc) · 1.64 KB
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Javascript EventBus Example</title>
<script type="text/javascript" src="eventbus.js"></script>
<script type="text/javascript">
var eventbus = yongboy.eventbus;
eventbus.on('myEvent', function () {
alert('Publish Message~');
});
eventbus.on('myEvent2', function () {
alert('Publish Message Again~');
});
eventbus.subscribe('myEvent3', function () {
alert('Publish Message 3rd Times~');
});
eventbus.on('myEvent4', function (msg) {
alert('Publish Message 4th Times with args : ' + msg);
});
eventbus.on('myEvent5', function (msg, id) {
alert('Publish Message 4th Times with args : ' + msg + " id : " + id);
});
function pubshMsg(event, args) {
eventbus.broadcast(event, args);
}
function pubshMsg2(event) {
eventbus.broadcast('myEvent5', 'EventBus Msg Here ..', 10);
}
</script>
</head>
<body>
<input type="button" value="Publish Message With myEvent" onClick="pubshMsg('myEvent')" />
<br />
<input type="button" value="Publish Message With myEvent2" onClick="pubshMsg('myEvent2')" />
<br />
<input type="button" value="Publish Message With myEvent3" onClick="pubshMsg('myEvent3')" />
<br/>
<input type="button" value="Publish Message With myEvent4" onClick="pubshMsg('myEvent4', 'EventBus Msg Here ..')" />
<br/>
<input type="button" value="Publish Message With myEvent5" onClick="pubshMsg2()" />
</body>
</html>