@theoplayer/react-native-engage
Version:
Engage connector for @theoplayer/react-native
48 lines (47 loc) • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DefaultCluster = void 0;
var _reactNativeEngage = require("@theoplayer/react-native-engage");
var _Cluster = require("../../api/cluster/Cluster");
class DefaultCluster extends _Cluster.Cluster {
constructor(engageClient, type, entities = []) {
super();
this.engageClient = engageClient;
this.type = type;
this.entities = entities;
}
get config() {
return this.clusterConfig;
}
set config(config) {
this.clusterConfig = config;
this.update();
}
update() {
this.engageClient.publish(this);
this.dispatchEvent(new _reactNativeEngage.ClusterEntitiesChangedEvent());
}
addEntity(entity, op = _reactNativeEngage.AddOperation.AddToFront) {
switch (op) {
case _reactNativeEngage.AddOperation.AddToBack:
this.entities = [...this.entities.filter(e => e.id !== entity.id), entity];
break;
case _reactNativeEngage.AddOperation.AddToFront:
this.entities = [entity, ...this.entities.filter(e => e.id !== entity.id)];
break;
}
this.update();
}
removeEntity(entity) {
this.entities = this.entities.filter(e => e.id !== entity.id);
this.update();
}
removeAllEntities() {
this.entities = [];
this.update();
}
}
exports.DefaultCluster = DefaultCluster;
//# sourceMappingURL=DefaultCluster.js.map