import { ActionPayload } from '@ulangi/ulangi-action' ; import * as _ from 'lodash' ; import { Event } from '../interfaces/Event' ; import { EventListener } from '../types/EventListener' ; export function on < K extends keyof ActionPayload > ( actionType , callback ) { return ( event ) : void => { if ( _ . isArray ( actionType ) ) { actionType . forEach ( ( type ) : void => { if ( event . action . is ( type ) ) { callback ( event . action . payload ) ; } } ) ; } else { if ( event . action . is ( actionType ) ) { callback ( event . action . payload ) ; } } } ; }