How to use WASM with OutSystems?
After saving the hello-world.go file we compile it by running the following command:
$ GOARCH=wasm GOOS=js go build -o app.bin hello-world.go
Now in the OutSystems Service Studio we are going to create a new application from scratch by selecting the New Application icon and choosing the From Scratch option.
For this example, we will create a reactive web app - that is, an app with a responsive interface that runs in the browser and adapts to all kinds of devices and screen sizes.
The final step is to enter a name and description, choose a color scheme, and create the app.
Now we create the application module by selecting the Create Module button.
This is the result - the file is under Scripts as wasm_exec.
Then we will create a Screen and call it HomePage.
At the HomePage screen that we have just created, we need to add the wasm_exec script as a Required Scripts.
This will force the script to load when we open this page. We set the role to Anonymous so that the whole world can see this page and add an OnReady event action.
Inside the OnReady action, we add a JS node to the flow, name it InitWASM, and add the following code inside the node:
This is the OnReady Action:
At the screen we add a Text widget to the Title and we name it T.
This will be the element that our WASM code will populate with the "Hello World from WASM! As a final step, we need to go to the Data Navigation Pane and upload the app.bin that we compiled earlier as a new resource. We need to change the Deploy Action to "Deploy to Target Directory" and set the Target Directory to "wasm".
It will look like this:
Finally just Publish and Open in the Browser.
On Part 2 we will extend this WASM application to make a simple calculation of adding two integer numbers.
The Go Language: