forked from openfin/java-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcounter_client.html
More file actions
53 lines (43 loc) · 1.39 KB
/
counter_client.html
File metadata and controls
53 lines (43 loc) · 1.39 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
52
53
<html>
<head>
<script>
let channelClient;
async function makeClient() {
const connectPayload = { payload: 'place connection payload here' };
const client = await fin.InterApplicationBus.Channel.connect('CounterJavaProvider', connectPayload);
return {
getValue: () => client.dispatch('getValue'),
increment: () => client.dispatch('increment'),
incrementBy: (x) => client.dispatch('incrementBy', { delta: x }),
}
}
function getCounterValue() {
channelClient.getValue().then(v => { document.getElementById("count").textContent = v.value; });
}
function incrementCounterValue() {
channelClient.increment().then(v => { document.getElementById("count").textContent = v.value; });
}
function incrementCounterValueBy(delta) {
channelClient.incrementBy(delta).then(v => { document.getElementById("count").textContent = v.value; });
}
document.addEventListener('DOMContentLoaded', () => {
fin.desktop.main(() => {
makeClient().then(async (clientBus) => {
channelClient = clientBus;
});
});
});
</script>
</head>
<body>
count: <span id="count">N/A</span>
<button onclick="getCounterValue()">Get</button>
<br>
<br>
<button onclick="incrementCounterValue()">Increment</button>
<br>
<br>
<input id="deltaValue"></input>
<button onclick="incrementCounterValueBy(document.getElementById('deltaValue').value)">IncrementBy</button>
</body>
</html>