subscriber在调用回调之前,应该先同步cache中的数据

This commit is contained in:
Xu Chang 2025-11-15 21:45:38 +08:00
parent 94dc93868c
commit 40a98dd51a
3 changed files with 3 additions and 3 deletions

View File

@ -94,11 +94,11 @@ export class SubScriber extends Feature {
}
});
socket.on('data', (opRecords, event) => {
this.cache.sync(opRecords);
const registered = this.eventMap[event];
if (registered) {
registered.callbacks.forEach((ele) => ele(event, opRecords));
}
this.cache.sync(opRecords);
});
socket.on('error', (errString) => {
console.error(errString);

View File

@ -98,11 +98,11 @@ class SubScriber extends Feature_1.Feature {
}
});
socket.on('data', (opRecords, event) => {
this.cache.sync(opRecords);
const registered = this.eventMap[event];
if (registered) {
registered.callbacks.forEach((ele) => ele(event, opRecords));
}
this.cache.sync(opRecords);
});
socket.on('error', (errString) => {
console.error(errString);

View File

@ -127,13 +127,13 @@ export class SubScriber<ED extends EntityDict & BaseEntityDict> extends Feature
socket.on(
'data',
(opRecords: OpRecord<ED>[], event: string) => {
this.cache.sync(opRecords);
const registered = this.eventMap[event];
if (registered) {
registered.callbacks.forEach(
(ele) => ele(event, opRecords)
);
}
this.cache.sync(opRecords);
}
);