Home Reference Source Test
public class | source

Event

Extends:

EventEmitter → Event

class Event is the primitive class for composing higher event-based class.

Example:

import { Event } from 'causal-net.core';

(async ()=>{
    let eventA = new Event();
    let eventB = new Event();    
    eventA.on('data', (data)=>{
        console.log({'event handler': data});
        return 'this is done';
    })
    console.log(await eventA.emit('data', [1,2,3]));
    console.log('send event');
    eventB.pipe(eventA);
    console.log(await eventB.emit('data', ['1,2,3']));
})();

Test:

Constructor Summary

Public Constructor
public

Method Summary

Public Methods
public

async emit(name: *, data: *): *

public

on(name: *, handler: *, bypass: boolean)

public

pipe(destStream: *)

Public Constructors

public constructor() source

Public Methods

public async emit(name: *, data: *): * source

Params:

NameTypeAttributeDescription
name *
data *

Return:

*

public on(name: *, handler: *, bypass: boolean) source

Params:

NameTypeAttributeDescription
name *
handler *
bypass boolean
  • optional
  • default: false

public pipe(destStream: *) source

Params:

NameTypeAttributeDescription
destStream *