"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.listenGlobalComponent = listenGlobalComponent;
exports.firstGlobalComponentPromise = firstGlobalComponentPromise;
function listenGlobalComponent(system, id, callback) {
    const { emitter } = system;
    const listener = (component) => {
        callback(component);
    };
    emitter.addListener(id, listener);
    return () => {
        emitter.removeListener(id, listener);
    };
}
function firstGlobalComponentPromise(system, id) {
    const { emitter } = system;
    const component = system.getLocalComponents(id)[0];
    if (component) {
        return Promise.resolve(component);
    }
    return new Promise((resolve) => {
        const listener = (component) => {
            emitter.removeListener(id, listener);
            resolve(component);
        };
        emitter.addListener(id, listener);
    });
}
//# sourceMappingURL=globalComponent.js.map