I integrated some WASM code (compiled from Go code) into Angular to use some functions. At the moment this is done only in one place and is thus not shared throughout the whole app. I just used the "standard" procedure for WASM and Go:
let go = new Go();
WebAssembly.instantiateStreaming(fetch('mywasm.wasm'), go.importObject).then((res) => {
go.run(res.instance);
myCoolWasmFunction();
});
However, I would like to execute WASM in multiple parts of the app and thus tried to move this into a service. I was able to use an RxJS subject and listen to "execution requests" in that function after go.run(...), but I could not return anything to other parts of the app.
Basically, I am searching for a clean and usable way to execute different functions exposed by wasm in the Angular app. Should I just put the wasm stuff into the index.html and create a service that just calls those "globally available" functions? How would I enable angular to recognize those, just with a .d.ts file?