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

on() method from fcf.EventEmitter class

on(string a_name, function a_cb)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Adds an event handler

Arguments

string a_name
- Event name

function a_cb
- Event handler function. The function has the following signature: (async or simple) a_cb(mixed a_data)
  • mixed a_data - Data passed when the event was fired

Example: Function application

class Test extends fcf.EventEmitter { }; let testObject = new Test(); testObject.on("call", (a_event)=>{ console.log(a_event) }); testObject.emit("call", {info: "value"});

Output:

{ info: 'value' }