"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const SharedObject_1 = require("../SharedObject");
const util_1 = require("./util");
class Counter {
    constructor(init) {
        this._data = init;
    }
    inc() {
        this._data++;
    }
    dec() {
        this._data--;
    }
}
const counter = new Counter(0);
const shared_counter = new SharedObject_1.SharedObject(counter);
const client0 = shared_counter.connect();
const client1 = shared_counter.connect();
const client2 = shared_counter.connect();
const { proxy: proxy0, emitter: emitter0, disconnect: disconnect0 } = client0;
const { proxy: proxy1, emitter: emitter1, disconnect: disconnect1 } = client1;
const { proxy: proxy2, emitter: emitter2, disconnect: disconnect2 } = client2;
const incCounter0 = (0, util_1.countEvent)(emitter0, 'inc');
const incCounter1 = (0, util_1.countEvent)(emitter1, 'inc');
const incCounter2 = (0, util_1.countEvent)(emitter2, 'inc');
proxy0.inc();
assert_1.default.equal(incCounter0.count, 0);
assert_1.default.equal(incCounter1.count, 1);
assert_1.default.equal(incCounter2.count, 1);
proxy1.inc();
assert_1.default.equal(incCounter0.count, 1);
assert_1.default.equal(incCounter1.count, 1);
assert_1.default.equal(incCounter2.count, 2);
disconnect2();
proxy1.inc();
assert_1.default.equal(incCounter0.count, 2);
assert_1.default.equal(incCounter1.count, 1);
assert_1.default.equal(incCounter2.count, 2);
//# sourceMappingURL=SharedObject.js.map