@signaldb/svelte 2.0.0-beta.15 → 2.0.0-beta.17

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.
@@ -148,11 +148,33 @@ class WorkerDataAdapter {
148
148
  // holding something else — a message lost, a query re-registered underneath, a host and an
149
149
  // adapter that disagree — applying it anyway would leave a result that silently drifts from
150
150
  // the store. Refusing it keeps the last coherent result instead, and the next full answer
151
- // puts things right.
152
- if (!(0, queryDelta_1.canApplyQueryDelta)(query.items, delta))
153
- return;
154
- if ((0, queryDelta_1.isEmptyQueryDelta)(delta))
151
+ // puts things right. A delta describing no change at all is refused for the simpler reason
152
+ // that there is nothing to apply.
153
+ //
154
+ // The *state* the message carries is not part of that judgement, and used to be dropped
155
+ // along with the delta. A host that cannot answer a query from its previous result announces
156
+ // `'active'`, re-executes, and answers with a delta — which is empty whenever the write left
157
+ // this query's result as it was. The query then stayed `'active'` here for good, because no
158
+ // further message was coming to correct it: `Cursor#isLoading()` reported a first result
159
+ // still pending forever, and every screen gated on it showed its loading state forever.
160
+ const canApply = (0, queryDelta_1.canApplyQueryDelta)(query.items, delta);
161
+ if (!canApply || (0, queryDelta_1.isEmptyQueryDelta)(delta)) {
162
+ if (state === query.state)
163
+ return;
164
+ this.updateQuery(collectionName, {
165
+ selector: query.selector,
166
+ options: query.options,
167
+ }, { state, error });
168
+ const settled = collectionQueries.get(id);
169
+ if (!settled)
170
+ return;
171
+ // An empty delta is passed on as it came: it settles the query without asking anyone to
172
+ // recompute a result that did not change. One that could not be applied is not, so the
173
+ // consumer re-reads and the disagreement ends there.
174
+ settled.stateChangeCallbacks
175
+ .forEach(callback => (0, queryDelta_1.callWithDelta)(callback, state, canApply ? delta : undefined));
155
176
  return;
177
+ }
156
178
  const pendingBefore = this.flattenPendingWrites(collectionName);
157
179
  const servedBefore = pendingBefore == null
158
180
  ? null
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@signaldb/svelte",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.15",
4
+ "version": "2.0.0-beta.17",
5
5
  "scripts": {
6
6
  "build": "tsc -d --noEmit false",
7
7
  "analyze-bundle": "bundle-analyzer ./dist --upload-token=$BUNDLE_ANALYZER_UPLOAD_TOKEN --bundle-name=@signaldb/svelte",