once() method from fcf.EventChannel class
Package: fcf-framework-core
File: fcf-framework-core:fcf.js
Available from version: 2.0.2
Adds an event handler that will only be called once. After the first call, the added event handler is removed from the processing queue.
Arguments
- Event name
- 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.
- The callback handler function.
Function signature: (async or simple)
-
object a_eventData - The event data that was passed to the send function -
object a_eventHeader - Event headerObject properties:
-
string name - Event name
-
Example: Function application
fcf.getEventChannel().once ("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' }