export function SynchronizedMixin(Superclass) { return class Synchronized extends Superclass { constructor(...args) { super(...args); this._idempotentPackets = []; } cleanPackets() { this._idempotentPackets = []; } destroy() {} fromNetwork(json) { this.fromJSON(json); } packets(informed) { return []; } packetsAreIdempotent() { return true; } packetsFor(informed) { if (this._idempotentPackets.length > 0) { return this._idempotentPackets; } let packets = this.packets(informed); if (!packets) { return []; } packets = Array.isArray(packets) ? packets : [packets]; if (this.packetsAreIdempotent()) { this._idempotentPackets = packets; } return packets; } synchronizationId() { return 0; } toNetwork(informed) { return this.toJSON(); } } }