-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
48 lines (44 loc) · 1.04 KB
/
app.js
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
// Use Vue with wasm
function createApp() {
new Vue({
el: "#app",
data: {
value1: '',
value2: '',
result: '',
quote: ''
},
methods: {
add: function () {
this.result = add(this.value1, this.value2)
},
subtract: function () {
this.result = subtract(this.value1, this.value2)
},
getQuote: function () {
let boundThis = this;
(async function () {
try {
const response = await getTaylorSwiftQuote('https://api.taylor.rest/')
const resJson = await response.json()
boundThis.quote = resJson['quote']
} catch (err) {
console.log(err)
return err
}
})()
}
}
})
}
async function main() {
const go = new Go();
const response = await fetch("lib.wasm");
const buffer = await response.arrayBuffer();
const result = await WebAssembly.instantiate(buffer, go.importObject);
go.run(result.instance)
createApp()
}
(async function () {
await main();
})();