@casual-simulation/aux-common
Version:
Common library for AUX projects
94 lines • 2.89 kB
JavaScript
import { Subscription } from 'rxjs';
export class ProxyBridgePartitionImpl {
get private() {
return this._partition.private;
}
get realtimeStrategy() {
return this._partition.realtimeStrategy;
}
get onBotsAdded() {
return this._partition.onBotsAdded;
}
get onBotsRemoved() {
return this._partition.onBotsRemoved;
}
get onBotsUpdated() {
return this._partition.onBotsUpdated;
}
get onStateUpdated() {
return this._partition.onStateUpdated;
}
get onError() {
return this._partition.onError;
}
get onEvents() {
return this._partition.onEvents;
}
get onStatusUpdated() {
return this._partition.onStatusUpdated;
}
get onVersionUpdated() {
return this._partition.onVersionUpdated;
}
get space() {
return this._partition.space;
}
set space(value) {
this._partition.space = value;
}
constructor(partition) {
this._partition = partition;
this._sub = new Subscription();
}
applyEvents(events) {
return this._partition.applyEvents(events);
}
async sendRemoteEvents(events) {
if (this._partition.sendRemoteEvents) {
await this._partition.sendRemoteEvents(events);
}
}
connect() {
return this._partition.connect();
}
async addListeners(onBotsAdded, onBotsRemoved, onBotsUpdated, onStateUpdated, onError, onEvents, onStatusUpdated, onVersionUpdated) {
if (onBotsAdded) {
this._sub.add(this.onBotsAdded.subscribe((bots) => onBotsAdded(bots)));
}
if (onBotsRemoved) {
this._sub.add(this.onBotsRemoved.subscribe((bots) => onBotsRemoved(bots)));
}
if (onBotsUpdated) {
this._sub.add(this.onBotsUpdated.subscribe((bots) => onBotsUpdated(bots)));
}
if (onStateUpdated) {
this._sub.add(this.onStateUpdated.subscribe((update) => onStateUpdated(update)));
}
if (onError) {
this._sub.add(this.onError.subscribe((err) => onError(err)));
}
if (onEvents) {
this._sub.add(this.onEvents.subscribe((events) => onEvents(events)));
}
if (onStatusUpdated) {
this._sub.add(this.onStatusUpdated.subscribe((status) => onStatusUpdated(status)));
}
if (onVersionUpdated) {
this._sub.add(this.onVersionUpdated.subscribe((version) => onVersionUpdated(version)));
}
}
async setSpace(space) {
this._partition.space = space;
}
get closed() {
return this._partition.closed;
}
unsubscribe() {
if (this.closed) {
return;
}
this._sub.unsubscribe();
return this._partition.unsubscribe();
}
}
//# sourceMappingURL=ProxyBridgePartition.js.map