"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const loggingService_1 = require("./loggingService");
const pubSubEventService_1 = require("./pubSubEventService");
const utilsInternal_1 = require("./utilsInternal");
class PromiseEventService {
    /**
     * Publish to the given topics the result of the given promise.
     * The payload of the event will be of type TResult.
     * @param topics
     * @param promise
     */
    static publish(topics, promise) {
        const topicsArray = utilsInternal_1.UtilsInternal.ensureArray(topics);
        promise
            .then((result) => {
            topicsArray.forEach((topic) => {
                pubSubEventService_1.PubSubEventService.publish(topic, result);
            });
        })
            .catch((error) => {
            loggingService_1.LoggingService.error(`PromiseEventService.publish: unable to publish result of rejected promise: ${error.message}`);
        });
    }
}
exports.PromiseEventService = PromiseEventService;
//# sourceMappingURL=promiseEventService.js.map