Module Function Event Builder

Within the context of module functions including main-page.js and app-flow.js, there is an event helper available to allow raising custom events, similar to the Fire Custom Event Action.

The helper is made available to the module function through a context passed to the Module classes constructor, and has two methods available.

Table 1-6 Module function event helper methods

Method Description
fireCustomEvent(name, payload) See Fire Custom Event Action.
fireNotificationEvent(options) See Fire Notification Event Action.

Example 1-79 Usage in a module function

'use strict';

define(function () {
  function MainPageModule(context) {
    this.eventHelper = context.getEventHelper();
  }

  MainPageModule.prototype.fireCustom = function (name, payload) {
    return this.eventHelper.fireCustomEvent(name, payload);
  }

  MainPageModule.prototype.fireNotification = function (subject, message) {
    return this.eventHelper.fireNotificationEvent({ subject, message, type: 'info' });
  }

  return MainPageModule;
});