@0xobelisk/ecs 1.2.0-pre.46 → 1.2.0-pre.48

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.
package/dist/index.js CHANGED
@@ -1176,7 +1176,7 @@ var ECSSubscription = class {
1176
1176
  /**
1177
1177
  * Listen to component changes with specific conditions
1178
1178
  */
1179
- onComponentCondition(componentType, filter, options) {
1179
+ onEntityComponent(componentType, entityId, options) {
1180
1180
  if (!isValidComponentType(componentType)) {
1181
1181
  return new import_client.Observable((observer) => {
1182
1182
  observer.error(new Error(`Invalid component type: ${componentType}`));
@@ -1198,22 +1198,26 @@ var ECSSubscription = class {
1198
1198
  (result) => observer.next(result),
1199
1199
  options.debounceMs
1200
1200
  ) : (result) => observer.next(result);
1201
- const observable = this.graphqlClient.subscribeToFilteredTableChanges(
1201
+ const primaryKeyField = this.getComponentPrimaryKeyField(componentType);
1202
+ const entityFilter = {
1203
+ [primaryKeyField]: { equalTo: entityId }
1204
+ };
1205
+ const observable = this.graphqlClient.subscribeToTableChanges(
1202
1206
  componentType,
1203
- filter,
1204
1207
  {
1205
1208
  initialEvent: options?.initialEvent ?? false,
1206
1209
  fields: subscriptionFields,
1210
+ filter: entityFilter,
1207
1211
  onData: (data) => {
1208
1212
  try {
1209
1213
  const pluralTableName = this.getPluralTableName(componentType);
1210
1214
  const nodes = data?.listen?.query?.[pluralTableName]?.nodes || [];
1211
1215
  nodes.forEach((node) => {
1212
1216
  if (node) {
1213
- const entityId = node.entityId || this.extractEntityId(node, componentType);
1214
- if (entityId) {
1217
+ const entityId2 = node.entityId || this.extractEntityId(node, componentType);
1218
+ if (entityId2) {
1215
1219
  const result = {
1216
- entityId,
1220
+ entityId: entityId2,
1217
1221
  data: node,
1218
1222
  changeType: "updated",
1219
1223
  timestamp: Date.now()
@@ -2122,10 +2126,10 @@ var DubheECSWorld = class {
2122
2126
  /**
2123
2127
  * Listen to component changes with specific conditions
2124
2128
  */
2125
- onComponentCondition(componentType, filter, options) {
2126
- return this.subscriptionSystem.onComponentCondition(
2129
+ onEntityComponent(componentType, entityId, options) {
2130
+ return this.subscriptionSystem.onEntityComponent(
2127
2131
  componentType,
2128
- filter,
2132
+ entityId,
2129
2133
  options
2130
2134
  );
2131
2135
  }
@@ -2433,14 +2437,10 @@ var DubheECSWorld = class {
2433
2437
  );
2434
2438
  }
2435
2439
  const subscriptionFields = options?.fields || resourceMetadata.fields.map((f) => f.name);
2436
- return this.graphqlClient.subscribeToFilteredTableChanges(
2437
- resourceType,
2438
- options?.filter,
2439
- {
2440
- ...options,
2441
- fields: subscriptionFields
2442
- }
2443
- );
2440
+ return this.graphqlClient.subscribeToTableChanges(resourceType, {
2441
+ ...options,
2442
+ fields: subscriptionFields
2443
+ });
2444
2444
  }
2445
2445
  };
2446
2446
  function createECSWorld(graphqlClient, config) {