@korajs/store 1.0.0-beta.6 → 1.0.0-beta.8

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.d.cts CHANGED
@@ -1016,6 +1016,7 @@ declare class QueryStore<T = CollectionRecord> {
1016
1016
  private listeners;
1017
1017
  private unsubscribeQuery;
1018
1018
  private active;
1019
+ private hasEmittedSnapshot;
1019
1020
  private readonly queryBuilder;
1020
1021
  constructor(queryBuilder: QueryBuilder<T>);
1021
1022
  /**
@@ -1026,6 +1027,11 @@ declare class QueryStore<T = CollectionRecord> {
1026
1027
  subscribe: (onStoreChange: () => void) => (() => void);
1027
1028
  /** Synchronous read of the latest query results. */
1028
1029
  getSnapshot: () => readonly T[];
1030
+ /**
1031
+ * Whether the underlying query subscription has delivered at least one
1032
+ * authoritative result for the current subscription lifecycle.
1033
+ */
1034
+ hasSnapshot: () => boolean;
1029
1035
  /** Tear down listeners and the underlying query subscription. */
1030
1036
  destroy(): void;
1031
1037
  private startSubscription;
package/dist/index.d.ts CHANGED
@@ -1016,6 +1016,7 @@ declare class QueryStore<T = CollectionRecord> {
1016
1016
  private listeners;
1017
1017
  private unsubscribeQuery;
1018
1018
  private active;
1019
+ private hasEmittedSnapshot;
1019
1020
  private readonly queryBuilder;
1020
1021
  constructor(queryBuilder: QueryBuilder<T>);
1021
1022
  /**
@@ -1026,6 +1027,11 @@ declare class QueryStore<T = CollectionRecord> {
1026
1027
  subscribe: (onStoreChange: () => void) => (() => void);
1027
1028
  /** Synchronous read of the latest query results. */
1028
1029
  getSnapshot: () => readonly T[];
1030
+ /**
1031
+ * Whether the underlying query subscription has delivered at least one
1032
+ * authoritative result for the current subscription lifecycle.
1033
+ */
1034
+ hasSnapshot: () => boolean;
1029
1035
  /** Tear down listeners and the underlying query subscription. */
1030
1036
  destroy(): void;
1031
1037
  private startSubscription;
package/dist/index.js CHANGED
@@ -3107,6 +3107,7 @@ var QueryStore = class {
3107
3107
  listeners = /* @__PURE__ */ new Set();
3108
3108
  unsubscribeQuery = null;
3109
3109
  active = false;
3110
+ hasEmittedSnapshot = false;
3110
3111
  queryBuilder;
3111
3112
  constructor(queryBuilder) {
3112
3113
  this.queryBuilder = queryBuilder;
@@ -3132,16 +3133,25 @@ var QueryStore = class {
3132
3133
  getSnapshot = () => {
3133
3134
  return this.snapshot;
3134
3135
  };
3136
+ /**
3137
+ * Whether the underlying query subscription has delivered at least one
3138
+ * authoritative result for the current subscription lifecycle.
3139
+ */
3140
+ hasSnapshot = () => {
3141
+ return this.hasEmittedSnapshot;
3142
+ };
3135
3143
  /** Tear down listeners and the underlying query subscription. */
3136
3144
  destroy() {
3137
3145
  this.stopSubscription();
3138
3146
  this.listeners.clear();
3139
3147
  this.snapshot = EMPTY_ARRAY;
3148
+ this.hasEmittedSnapshot = false;
3140
3149
  }
3141
3150
  startSubscription() {
3142
3151
  this.active = true;
3143
3152
  this.unsubscribeQuery = this.queryBuilder.subscribe((results) => {
3144
3153
  if (!this.active) return;
3154
+ this.hasEmittedSnapshot = true;
3145
3155
  this.snapshot = Object.freeze([...results]);
3146
3156
  this.notifyListeners();
3147
3157
  });