@trudb/tru-common-lib 0.2.502 → 0.2.505

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,6 +8178,13 @@ class TruDataChangeParser {
8178
8178
  dataChanged(change) {
8179
8179
  this.dataChanged$.next(change);
8180
8180
  }
8181
+ destroy() {
8182
+ this.dataContext = null;
8183
+ this.entity = null;
8184
+ this.tableName = null;
8185
+ this.addEntity = null;
8186
+ this.getLatestResults = null;
8187
+ }
8181
8188
  constructor(connection, appEnviroment, user, dataContext, globalDataContext, entity, tableName, addEntity, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded, modelTypeLookup, modelPropertyLookup) {
8182
8189
  this.appEnvionment = appEnviroment;
8183
8190
  this.user = user;
@@ -8198,8 +8205,8 @@ class TruDataChangeParser {
8198
8205
  });
8199
8206
  }
8200
8207
  findEntityInCache = (change) => {
8201
- var entityAccessor = this.dataContext.entityAccess();
8202
- return entityAccessor.searchByRefCacheOnly(this.types.getType(change.tableName), parseInt(change.tableRef, 10), true);
8208
+ var entityAccessor = this.dataContext?.entityAccess();
8209
+ return entityAccessor?.searchByRefCacheOnly(this.types.getType(change.tableName), parseInt(change.tableRef, 10), true);
8203
8210
  };
8204
8211
  findEntityInGlobalCache = (change) => {
8205
8212
  var entityAccessor = this.globalDataContext.entityAccess();
@@ -8275,17 +8282,17 @@ class TruDataChangeParser {
8275
8282
  });
8276
8283
  };
8277
8284
  entityFoundByQuery = (change) => {
8278
- var entityAccessor = this.dataContext.entityAccess();
8279
- var entities = entityAccessor.searchByRefArrayCacheOnly(this.entity, this.getLatestQuery(), [change.tableRef]);
8285
+ let entityAccessor = this.dataContext?.entityAccess();
8286
+ let entities = entityAccessor?.searchByRefArrayCacheOnly(this.entity, this.getLatestQuery(), [change.tableRef]);
8280
8287
  if (!entities?.length) {
8281
- var entityAccessor = this.globalDataContext.entityAccess();
8288
+ let entityAccessor = this.globalDataContext.entityAccess();
8282
8289
  entities = entityAccessor.searchByRefArrayCacheOnly(this.entity, this.getLatestQuery(), [change.tableRef]);
8283
8290
  }
8284
8291
  return entities === null ? 0 : entities.length;
8285
8292
  };
8286
8293
  getEntityFromServer = (change) => {
8287
- var entityAccessor = this.dataContext.entityAccess();
8288
- var entitiy = entityAccessor.searchByRefWithQuery(this.entity, this.getLatestQuery(), change.tableRef);
8294
+ var entityAccessor = this.dataContext?.entityAccess();
8295
+ var entitiy = entityAccessor?.searchByRefWithQuery(this.entity, this.getLatestQuery(), change.tableRef);
8289
8296
  return entitiy;
8290
8297
  };
8291
8298
  getEntityFromResults = (results, change) => {
@@ -8370,7 +8377,7 @@ class TruDataChangeParser {
8370
8377
  }
8371
8378
  }
8372
8379
  else if (!globalEntity) {
8373
- var newEntity = this.globalDataContext.entityAccess().add(this.entity, this.contextFilters);
8380
+ let newEntity = this.globalDataContext.entityAccess().add(this.entity, this.contextFilters);
8374
8381
  const pkeyName = change.tableName + 'Ref';
8375
8382
  newEntity[pkeyName] = change.tableRef;
8376
8383
  this.applyPropertyChanges(change, newEntity);
@@ -8441,6 +8448,7 @@ class TruConnectionHub {
8441
8448
  modelTypeLookup;
8442
8449
  modelPropertyLookup;
8443
8450
  connection;
8451
+ parser;
8444
8452
  constructor(dataContext, appEnvironment, user, modelTypeLookup, modelPropertyLookup) {
8445
8453
  this.dataContext = dataContext;
8446
8454
  this.appEnvironment = appEnvironment;
@@ -8478,7 +8486,11 @@ class TruConnectionHub {
8478
8486
  this.connect();
8479
8487
  };
8480
8488
  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();
8489
+ 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);
8490
+ return this.parser.onDataChanged();
8491
+ };
8492
+ destroy = () => {
8493
+ this.parser.destroy();
8482
8494
  };
8483
8495
  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
8496
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TruConnectionHub, providedIn: 'root' });