onMessage
onMessage
Called when a message sent from another form arrives.
Parameters
name(string): The message namedata(dynamic): The value sent along with the message
Returns: No return value — this is a callback, so its return value isn't used.
Description
When another form — a page, a popup — sends a message, this function is called so the receiving side can handle it. Use it to pass values between forms as events, without binding data directly between them.
Example
function onMessage(name, data) {
if (name === "refresh") {
$vm.requestData("mainList");
}
}
Related and cautions
- The sending side decides which
nameto use, and you have to agree on it separately — nothing enforces the name itself. - To keep a single value continuously in sync, a Variable or a widget property binding fits better than a message.
onMessageis closer to a one-off notification that an event happened.