在apploader的事务提交前发送更新的数据到DataSubscriber
This commit is contained in:
parent
d5c1cc9e71
commit
a3438f3ebf
|
|
@ -117,9 +117,25 @@ export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Async
|
|||
this.aspectDict = Object.assign({}, generalAspectDict, this.requireSth('lib/aspects/index'));
|
||||
this.dbStore = new DbStore<ED, Cxt>(storageSchema, contextBuilder, dbConfig, ActionCascadePathGraph, RelationCascadePathGraph, deducedRelationMap,
|
||||
selectFreeEntities, createFreeEntities, updateFreeEntities);
|
||||
this.contextBuilder = contextBuilder;
|
||||
if (io) {
|
||||
this.dataSubscriber = new DataSubscriber(io, (scene) => this.contextBuilder(scene)(this.dbStore));
|
||||
this.contextBuilder = (scene) => async (store) => {
|
||||
const context = await contextBuilder(scene)(store);
|
||||
|
||||
// 注入在提交前向dataSubscribe
|
||||
const originCommit = context.commit;
|
||||
context.commit = async () => {
|
||||
const { opRecords } = context;
|
||||
const userId = context.getCurrentUserId();
|
||||
|
||||
originCommit.call(context);
|
||||
};
|
||||
|
||||
return context;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.contextBuilder = contextBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { EntityDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict, OpRecord } from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { Server } from 'socket.io';
|
||||
|
|
@ -25,4 +25,8 @@ export default class DataSubscriber<ED extends EntityDict & BaseEntityDict, Cont
|
|||
});
|
||||
})
|
||||
}
|
||||
|
||||
onDataCommited(records: OpRecord<ED>[], userId?: string) {
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue