@trudb/tru-common-lib 0.2.502 → 0.2.506

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8178,7 +8178,14 @@ class TruDataChangeParser {
8178
8178
  dataChanged(change) {
8179
8179
  this.dataChanged$.next(change);
8180
8180
  }
8181
- constructor(connection, appEnviroment, user, dataContext, globalDataContext, entity, tableName, addEntity, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded, modelTypeLookup, modelPropertyLookup) {
8181
+ destroy() {
8182
+ this.dataContext = null;
8183
+ this.entity = null;
8184
+ this.tableName = null;
8185
+ this.addEntity = null;
8186
+ this.getLatestResults = null;
8187
+ }
8188
+ constructor(connection, appEnviroment, user, dataContext, globalDataContext, entity, tableName, addEntity, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded, modelTypeLookup, modelPropertyLookup, destroyParser = null) {
8182
8189
  this.appEnvionment = appEnviroment;
8183
8190
  this.user = user;
8184
8191
  this.dataContext = dataContext;
@@ -8196,10 +8203,11 @@ class TruDataChangeParser {
8196
8203
  connection.on("change", (payload) => {
8197
8204
  this.update(payload);
8198
8205
  });
8206
+ destroyParser = this.destroy;
8199
8207
  }
8200
8208
  findEntityInCache = (change) => {
8201
- var entityAccessor = this.dataContext.entityAccess();
8202
- return entityAccessor.searchByRefCacheOnly(this.types.getType(change.tableName), parseInt(change.tableRef, 10), true);
8209
+ var entityAccessor = this.dataContext?.entityAccess();
8210
+ return entityAccessor?.searchByRefCacheOnly(this.types.getType(change.tableName), parseInt(change.tableRef, 10), true);
8203
8211
  };
8204
8212
  findEntityInGlobalCache = (change) => {
8205
8213
  var entityAccessor = this.globalDataContext.entityAccess();
@@ -8275,17 +8283,17 @@ class TruDataChangeParser {
8275
8283
  });
8276
8284
  };
8277
8285
  entityFoundByQuery = (change) => {
8278
- var entityAccessor = this.dataContext.entityAccess();
8279
- var entities = entityAccessor.searchByRefArrayCacheOnly(this.entity, this.getLatestQuery(), [change.tableRef]);
8286
+ let entityAccessor = this.dataContext?.entityAccess();
8287
+ let entities = entityAccessor?.searchByRefArrayCacheOnly(this.entity, this.getLatestQuery(), [change.tableRef]);
8280
8288
  if (!entities?.length) {
8281
- var entityAccessor = this.globalDataContext.entityAccess();
8289
+ let entityAccessor = this.globalDataContext.entityAccess();
8282
8290
  entities = entityAccessor.searchByRefArrayCacheOnly(this.entity, this.getLatestQuery(), [change.tableRef]);
8283
8291
  }
8284
8292
  return entities === null ? 0 : entities.length;
8285
8293
  };
8286
8294
  getEntityFromServer = (change) => {
8287
- var entityAccessor = this.dataContext.entityAccess();
8288
- var entitiy = entityAccessor.searchByRefWithQuery(this.entity, this.getLatestQuery(), change.tableRef);
8295
+ var entityAccessor = this.dataContext?.entityAccess();
8296
+ var entitiy = entityAccessor?.searchByRefWithQuery(this.entity, this.getLatestQuery(), change.tableRef);
8289
8297
  return entitiy;
8290
8298
  };
8291
8299
  getEntityFromResults = (results, change) => {
@@ -8370,7 +8378,7 @@ class TruDataChangeParser {
8370
8378
  }
8371
8379
  }
8372
8380
  else if (!globalEntity) {
8373
- var newEntity = this.globalDataContext.entityAccess().add(this.entity, this.contextFilters);
8381
+ let newEntity = this.globalDataContext.entityAccess().add(this.entity, this.contextFilters);
8374
8382
  const pkeyName = change.tableName + 'Ref';
8375
8383
  newEntity[pkeyName] = change.tableRef;
8376
8384
  this.applyPropertyChanges(change, newEntity);
@@ -8441,6 +8449,7 @@ class TruConnectionHub {
8441
8449
  modelTypeLookup;
8442
8450
  modelPropertyLookup;
8443
8451
  connection;
8452
+ parser;
8444
8453
  constructor(dataContext, appEnvironment, user, modelTypeLookup, modelPropertyLookup) {
8445
8454
  this.dataContext = dataContext;
8446
8455
  this.appEnvironment = appEnvironment;
@@ -8478,7 +8487,11 @@ class TruConnectionHub {
8478
8487
  this.connect();
8479
8488
  };
8480
8489
  subscribe = (dataContext, entity, tableName, addEntity, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded) => {
8481
- return new TruDataChangeParser(this.connection, this.appEnvironment, this.user, dataContext, this.appEnvironment.globalDataContext, entity, tableName, addEntity, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded, this.modelTypeLookup, this.modelPropertyLookup).onDataChanged();
8490
+ this.parser = new TruDataChangeParser(this.connection, this.appEnvironment, this.user, dataContext, this.appEnvironment.globalDataContext, entity, tableName, addEntity, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded, this.modelTypeLookup, this.modelPropertyLookup);
8491
+ return this.parser.onDataChanged();
8492
+ };
8493
+ destroy = () => {
8494
+ this.parser.destroy();
8482
8495
  };
8483
8496
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TruConnectionHub, deps: [{ token: TruDataContext }, { token: TruAppEnvironment }, { token: TruUser }, { token: TruModelTypeLookup }, { token: TruModelPropertyLookup }], target: i0.ɵɵFactoryTarget.Injectable });
8484
8497
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TruConnectionHub, providedIn: 'root' });