"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.watchUnitSpecEvent = void 0;
const callAll_1 = require("../util/call/callAll");
const watchUnitSpecEvent = (event, unit, callback) => {
    const all = [];
    const listener = (pinId, pin, take) => {
        callback({
            type: 'unit',
            event,
            data: { pinId },
        });
    };
    unit.addListener(event, listener);
    return () => {
        (0, callAll_1.callAll)(all)();
        unit.removeListener(event, listener);
    };
};
exports.watchUnitSpecEvent = watchUnitSpecEvent;
//# sourceMappingURL=watchUnitSpecEvent.js.map