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']));
})();
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:
Name | Type | Attribute | Description |
name | * | ||
data | * |
Return:
* |
public on(name: *, handler: *, bypass: boolean) source
Params:
Name | Type | Attribute | Description |
name | * | ||
handler | * | ||
bypass | boolean |
|
public pipe(destStream: *) source
Params:
Name | Type | Attribute | Description |
destStream | * |