FCF 2.0 development in progress...
> > > > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

on() method from fcf.EventChannel class

on(staring a_eventName, function a_callback)
on(staring a_eventName, object a_options, function a_callback)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Adding an event handler

Arguments

string a_eventName
- Event name

object a_options
- Object with additional options
  • number level = 0 - The callback processing order level. The order in which handlers are called is from lowest to highest level.

function a_callback
- The callback handler function.

Function signature: (async or simple) a_callback(object a_eventData, object a_eventHeader)

  • object a_eventData - The event data that was passed to the send function

  • object a_eventHeader - Event header

    Object properties:

    • string name - Event name

Example: Function application

fcf.getEventChannel().on("test_event", (a_eventData, a_eventHeader)=>{ console.log("Event data: ", a_eventData); console.log("Event header:", a_eventHeader); }); fcf.getEventChannel().send("test_event", {field1: "value1"});

Output:

Event data: { field1: 'value1' } Event header: { name: 'test_event' }