In this guide we will learn how to comunicate with nunu applications embeded inside a webpage using messages and how to use DOM elements to controll app content.

To explore more about communication check the NunuApp API documentation.

Message communication

To comunicate with the running application a message comunication model is used. The app or the page can send messages to each other that will be catched by callbacks used to process the information sent between them.

Its also possible to communicate between apps running on the same page, to achieve this we can pass the app objects from the page to the apps.

Page to app

To send a message from the webpage to the nunuStudio aplication running the use the sendData(data) method. Data can be anything, assuming that the nunuApp is on the same JS context as the sender its possible send even object references.

To receive these messages inside the app we need to create a onAppData

function onAppData(data)

App to page

Before sending data from the nunu app to the webpage we need to define a onMessageReceive callback to process received messages.

This callback can be defined using the code shown bellow.