Skip to content

Commit d3d63d0

Browse files
committed
Rename DbWorker message types for clarity
Renamed the 'onChange' message type to 'onQueryPatches' and 'onReceive' to 'refreshQueries' throughout the Db worker, Evolu instance, and related tests.
1 parent e7ba922 commit d3d63d0

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

packages/common/src/Evolu/Db.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ export type DbWorkerOutput =
127127
| TransferableError;
128128
}
129129
| {
130-
readonly type: "onChange";
130+
readonly type: "onQueryPatches";
131131
readonly tabId: Id;
132132
readonly queryPatches: ReadonlyArray<QueryPatches>;
133133
readonly onCompleteIds: ReadonlyArray<CallbackId>;
134134
}
135135
| {
136-
readonly type: "onReceive";
136+
readonly type: "refreshQueries";
137137
readonly tabId?: Id;
138138
}
139139
| {
@@ -289,7 +289,7 @@ const createDbWorkerDeps =
289289
postMessage({ type: "onError", error });
290290
},
291291
onReceive: () => {
292-
postMessage({ type: "onReceive" });
292+
postMessage({ type: "refreshQueries" });
293293
},
294294
});
295295
if (!sync.ok) return sync;
@@ -449,16 +449,16 @@ const handlers: Omit<MessageHandlers<DbWorkerInput, DbWorkerDeps>, "init"> = {
449449
);
450450
if (!queryPatches.ok) return queryPatches;
451451

452-
// Notify the tab that performed the mutation.
452+
// Update the tab that performed the mutation.
453453
deps.postMessage({
454-
type: "onChange",
454+
type: "onQueryPatches",
455455
tabId: message.tabId,
456456
queryPatches: queryPatches.value,
457457
onCompleteIds: message.onCompleteIds,
458458
});
459459

460460
// Notify other tabs to refresh their queries.
461-
deps.postMessage({ type: "onReceive", tabId: message.tabId });
461+
deps.postMessage({ type: "refreshQueries", tabId: message.tabId });
462462

463463
return ok();
464464
});
@@ -478,7 +478,7 @@ const handlers: Omit<MessageHandlers<DbWorkerInput, DbWorkerDeps>, "init"> = {
478478
}
479479

480480
deps.postMessage({
481-
type: "onChange",
481+
type: "onQueryPatches",
482482
tabId: message.tabId,
483483
queryPatches: queryPatches.value,
484484
onCompleteIds: [],

packages/common/src/Evolu/Evolu.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ const createEvoluInstance =
699699
break;
700700
}
701701

702-
case "onChange": {
702+
case "onQueryPatches": {
703703
if (message.tabId !== getTabId()) return;
704704

705705
const state = rowsStore.get();
@@ -731,7 +731,7 @@ const createEvoluInstance =
731731
break;
732732
}
733733

734-
case "onReceive": {
734+
case "refreshQueries": {
735735
if (message.tabId && message.tabId === getTabId()) return;
736736

737737
loadingPromises.releaseUnsubscribed();

packages/common/test/Evolu/Db.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,11 @@ test("local mutations", async () => {
358358
},
359359
],
360360
"tabId": "LhGnhts9rNnUeri8bzhS5",
361-
"type": "onChange",
361+
"type": "onQueryPatches",
362362
},
363363
{
364364
"tabId": "LhGnhts9rNnUeri8bzhS5",
365-
"type": "onReceive",
365+
"type": "refreshQueries",
366366
},
367367
]
368368
`);
@@ -386,7 +386,7 @@ test("local mutations", async () => {
386386
},
387387
],
388388
"tabId": "LhGnhts9rNnUeri8bzhS5",
389-
"type": "onChange",
389+
"type": "onQueryPatches",
390390
},
391391
]
392392
`,
@@ -466,11 +466,11 @@ test("local mutations", async () => {
466466
},
467467
],
468468
"tabId": "LhGnhts9rNnUeri8bzhS5",
469-
"type": "onChange",
469+
"type": "onQueryPatches",
470470
},
471471
{
472472
"tabId": "LhGnhts9rNnUeri8bzhS5",
473-
"type": "onReceive",
473+
"type": "refreshQueries",
474474
},
475475
]
476476
`);
@@ -625,11 +625,11 @@ test("sync mutations", async () => {
625625
},
626626
],
627627
"tabId": "LhGnhts9rNnUeri8bzhS5",
628-
"type": "onChange",
628+
"type": "onQueryPatches",
629629
},
630630
{
631631
"tabId": "LhGnhts9rNnUeri8bzhS5",
632-
"type": "onReceive",
632+
"type": "refreshQueries",
633633
},
634634
]
635635
`);
@@ -765,11 +765,11 @@ test("sync mutations", async () => {
765765
},
766766
],
767767
"tabId": "LhGnhts9rNnUeri8bzhS5",
768-
"type": "onChange",
768+
"type": "onQueryPatches",
769769
},
770770
{
771771
"tabId": "LhGnhts9rNnUeri8bzhS5",
772-
"type": "onReceive",
772+
"type": "refreshQueries",
773773
},
774774
]
775775
`);
@@ -913,11 +913,11 @@ test("sync mutations", async () => {
913913
},
914914
],
915915
"tabId": "LhGnhts9rNnUeri8bzhS5",
916-
"type": "onChange",
916+
"type": "onQueryPatches",
917917
},
918918
{
919919
"tabId": "LhGnhts9rNnUeri8bzhS5",
920-
"type": "onReceive",
920+
"type": "refreshQueries",
921921
},
922922
]
923923
`);

0 commit comments

Comments
 (0)