/**
 * A Reactor that only sends one type of event.
 */ import { IMutableReactor , IReactor , Reactor } from './Reactor' ; import { EventListener , RegisteredEventListener } from './EventListener' ; const EVENT_NAME = 'event' ; export class SimpleReactor < V > implements ISimpleReactor < V > { private readonly delegate : IMutableReactor < V > ; constructor ( delegate = new Reactor < V > ( ) ) { this . delegate = delegate ; this . delegate . registerEvent ( EVENT_NAME ) ; } public dispatchEvent ( value ) { this . delegate . dispatchEvent ( EVENT_NAME , value ) ; } public clear ( ) { this . delegate . clearEvent ( EVENT_NAME ) ; } public addEventListener ( eventListener ) { return this . delegate . addEventListener ( EVENT_NAME , eventListener ) ; } public once ( ) { return this . delegate . once ( EVENT_NAME ) ; } public removeEventListener ( eventListener ) { return this . delegate . removeEventListener ( EVENT_NAME , eventListener ) ; } public size ( ) { return this . delegate . size ( EVENT_NAME ) ; } /**
     *
     */ public getEventListeners ( ) { return this . delegate . getEventListeners ( EVENT_NAME ) ; } } export interface ISimpleReactor < V > { once ( ) : Promise < V > ; /**
     * Add the listener and return the listener that was added.  This allows you
     * to later remove the listener if necessary.
     */ addEventListener ( eventListener ) : RegisteredEventListener < V > ; removeEventListener ( eventListener ) : boolean ; dispatchEvent ( value ) : void ; /**
     * Remove all event listeners.
     */ clear ( ) : void ; /**
     * Return the total number of listeners added.
     */ size ( ) : number ; } export interface IEventDispatcher < V > extends ISimpleReactor < V > { }