type Cb = ( ... args : any [ ] ) => void ; const dispatchConstructor = ( ) => { const listeners = { } ; return { pub : ( event , ... args ) => { if ( event in listeners ) { listeners [ event ] . forEach ( ( cb ) => cb ( ... args ) ) ; } } , sub : ( event , cb ) => { if ( event in listeners ) { listeners [ event ] . push ( cb ) ; } else { listeners [ event ] = [ cb ] ; } } , unsub : ( event , cb ) => { if ( event in listeners ) { for ( let i = 0 ; i < listeners . length ; i ++ ) { if ( listeners [ i ] === cb ) listeners . splice ( i , 1 ) ; } } } , } ; } ; const dispatch = dispatchConstructor ( ) ; export const sub = dispatch . sub ; export const unsub = dispatch . unsub ; export const pub = dispatch . pub ; export const processAnyBuffered = ( _event ) => { } ;