send() method from fcf.EventChannel class
Package: fcf-framework-core
File: fcf-framework-core:fcf.js
Available from version: 2.0.2
Performs an event dispatch
Arguments
- Event name
- Extends options:
-
boolean exresult =false - Format of the result returned by the method through thefcf.Actions objectIf 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.
-
- Event data object
Result
- 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' } }