"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Semifunctional_1 = require("../../../../Class/Semifunctional");
const _ids_1 = require("../../../_ids");
class Interval extends Semifunctional_1.Semifunctional {
    constructor(system) {
        super({
            fi: ['ms'],
            o: ['ms'],
            i: ['done'],
        }, {}, system, _ids_1.ID_TIMER);
        this._interval = null;
        this.addListener('reset', this._reset);
        this.addListener('destroy', this._reset);
    }
    _reset() {
        if (this._interval !== null) {
            clearInterval(this._interval);
            this._interval = null;
        }
    }
    f({ ms }, done) {
        this._reset();
        // @ts-ignore
        this._interval = setInterval(() => {
            this.pushOutput('ms', ms);
        }, ms);
    }
    d() {
        this._reset();
        this._forward_all_empty();
    }
    onIterDataInputData(name, data) {
        // if (name === 'done') {
        this._reset();
        this._done({});
        // }
    }
}
exports.default = Interval;
//# sourceMappingURL=index.js.map