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

send() method from fcf.EventChannel class

fcf.Actions->mixed send(string a_eventName, object a_event)
fcf.Actions->mixed send(string a_eventName, object a_eventOptions, object a_event)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Performs an event dispatch

Arguments

string a_eventName
- Event name

object a_eventOptions
- Extends options:
  • boolean exresult = false - Format of the result returned by the method through the fcf.Actions object

    If this option equal true, then method result an object with next fields:

    • object event - Modified a_event argument data
    • object header - Event header

    If this option is false, then the result of the method will be the modified data of the a_event argument.

object a_event
- Event data object
Result
fcf.Actions->mixed
- Returns a lazy action object that returns an event data object

Example: Function application

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

Output:

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

Example: Function application (exresult)

fcf.getEventChannel().on("test_event", (a_eventData, a_eventHeader)=>{ console.log("Event data: ", a_eventData); console.log("Event header: ", a_eventHeader); }); let eventData = await fcf.getEventChannel().send("test_event", {exresult: true}, {field1: "value1"}); console.log("Result event data:", eventData);

Output:

Event data: { field1: 'value1' } Event header: { name: 'test_event' } Result event data: { event: { field1: 'value1' }, header: { name: 'test_event' } }