@statezero/core 0.1.23 → 0.1.24

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.
@@ -80,7 +80,7 @@ export class SyncManager {
80
80
  this.followedModels.set(registry, models);
81
81
  if (models.has(modelClass))
82
82
  return;
83
- const alreadyFollowed = [...this.followedModels.values()].some(set => set.has(modelClass));
83
+ const alreadyFollowed = [...this.followedModels.values()].some((set) => set.has(modelClass));
84
84
  models.add(modelClass);
85
85
  if (!alreadyFollowed) {
86
86
  getEventReceiver(modelClass.configKey)?.subscribe(modelClass.modelName, this.handleEvent);
@@ -91,7 +91,7 @@ export class SyncManager {
91
91
  if (!models)
92
92
  return;
93
93
  models.delete(modelClass);
94
- const stillFollowed = [...this.followedModels.values()].some(set => set.has(modelClass));
94
+ const stillFollowed = [...this.followedModels.values()].some((set) => set.has(modelClass));
95
95
  if (!stillFollowed) {
96
96
  getEventReceiver(modelClass.configKey)?.unsubscribe(modelClass.modelName, this.handleEvent);
97
97
  }
@@ -104,10 +104,10 @@ export class SyncManager {
104
104
  this.registries.delete(registry.constructor.name);
105
105
  }
106
106
  isQuerysetFollowed(queryset) {
107
+ const activeSemanticKeys = new Set([...this.followedQuerysets].map((qs) => qs.semanticKey));
107
108
  let current = queryset;
108
- // All followed querysets and their descendents get updated
109
109
  while (current) {
110
- if (this.followedQuerysets.has(current)) {
110
+ if (activeSemanticKeys.has(current.semanticKey)) {
111
111
  return true;
112
112
  }
113
113
  current = current.__parent;
@@ -127,7 +127,7 @@ export class SyncManager {
127
127
  const followingQuerysets = registry.followingQuerysets.get(semanticKey);
128
128
  if (followingQuerysets) {
129
129
  // Use some() to break early when we find a match
130
- const shouldSync = [...followingQuerysets].some(queryset => {
130
+ const shouldSync = [...followingQuerysets].some((queryset) => {
131
131
  return this.isQuerysetFollowed(queryset);
132
132
  });
133
133
  if (shouldSync) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statezero/core",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "type": "module",
5
5
  "module": "ESNext",
6
6
  "description": "The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate",