"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CallbackConnection = void 0;
const enum_1 = require("../../model/enum");
const help_1 = require("../../help");
class CallbackConnection {
    constructor() {
        this.statusFind = '';
    }
    onChange(event) {
        return __awaiter(this, void 0, void 0, function* () {
            let change = null;
            while (true) {
                if (this.statusFind !== change) {
                    change = this.statusFind;
                    event && event(change);
                }
                yield (0, help_1.sleep)(100);
            }
        });
    }
    on(type, callback) {
        return __awaiter(this, void 0, void 0, function* () {
            switch (type) {
                case enum_1.onMode.connection:
                    this.onChange((event) => {
                        if (event.onType === enum_1.onMode.connection) {
                            callback(event);
                        }
                    });
            }
        });
    }
}
exports.CallbackConnection = CallbackConnection;
//# sourceMappingURL=callback-connect.layes.js.map