import { LoggingService } from "./loggingService" ; import { PubSubEventService } from "./pubSubEventService" ; import { UtilsInternal } from "./utilsInternal" ; export class PromiseEventService { param topics param promise public static publish < TResult > ( topics , promise ) { const topicsArray = UtilsInternal . ensureArray ( topics ) ; promise . then ( ( result ) => { topicsArray . forEach ( ( topic ) => { PubSubEventService . publish ( topic , result ) ; } ) ; } ) . catch ( ( error ) => { LoggingService . error ( `PromiseEventService.publish: unable to publish result of rejected promise: ${ error . message }` ) ; } ) ; } }