"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.watchGraphUnit = watchGraphUnit;
const Graph_1 = require("../Class/Graph");
const GRAPH_DEFAULT_EVENTS_1 = require("../constant/GRAPH_DEFAULT_EVENTS");
const callAll_1 = require("../util/call/callAll");
const watchGraphInternal_1 = require("./graph/watchGraphInternal");
function watchGraphUnit(unit, events = GRAPH_DEFAULT_EVENTS_1.GRAPH_DEFAULT_EVENTS, callback) {
    let all = [];
    if (unit instanceof Graph_1.Graph) {
        for (const event of events) {
            const watcher = watchGraphInternal_1.GRAPH_EVENT_TO_WATCH[event];
            if (watcher) {
                all.push(watcher(event, unit, callback));
            }
        }
    }
    let unlisten = (0, callAll_1.callAll)(all);
    return unlisten;
}
//# sourceMappingURL=watchGraphUnit.js.map