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

once() method from fcf.EventChannel class

once(staring a_eventName, function a_callback)
once(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

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

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().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' }