"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const _ids_1 = require("../../../../_ids");
class Subscribe extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['obj', 'path', 'key'],
            fo: [],
            i: [],
            o: ['type', 'path', 'key', 'data'],
        }, {
            input: {
                obj: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_SUBSCRIBE);
        this._unlisten = undefined;
    }
    async f({ obj, path, key }, done, fail) {
        try {
            this._unlisten = obj.subscribe(path, key, (type, path_, key_, data) => {
                this._output.type.push(type);
                this._output.key.push(key_);
                this._output.path.push(path_);
                this._output.data.push(data);
            });
        }
        catch (err) {
            fail(err.message);
            return;
        }
    }
    d() {
        if (this._unlisten) {
            this._unlisten();
            this._unlisten = undefined;
        }
    }
}
exports.default = Subscribe;
//# sourceMappingURL=index.js.map