Introducing the UI manager
At some point, we will need to have a class that is responsible for the workflow of the user experience. For example, when a user clicks on the Add to cart
button, the product has to be added to the cart at the server level and the user interface has to be updated.
The UI manager takes responsibility for managing the workflow of the user experience, handling all communication with the server when needed, and is used as an entry point to start the Scala.js code. This is the main entry point of our client application when the application is executed in the browser.
For communicating with the server, we are going to use jQuery. This JavaScript library is widely used and is a reference in the JavaScript world.
This is one of the advantages of Scala.js. We can use existing JavaScript libraries, such as jQuery, from Scala. To use existing JavaScript libraries, we only need to define an interface, which is called a facade in Scala.js. The facade can be seen as an interface...