fix(core): update

This commit is contained in:
Philipp Kunz 2023-08-16 13:16:39 +02:00
parent 4ac8a4c0cd
commit 49b11b17ce
3 changed files with 16 additions and 5 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartdata',
version: '5.0.31',
version: '5.0.32',
description: 'do more with data'
}

View File

@ -56,8 +56,10 @@ export class SmartdataDistributedCoordinator extends plugins.taskbuffer.distribu
public async stop() {
await this.asyncExecutionStack.getExclusiveExecutionSlot(async () => {
if (this.ownInstance?.data.elected) {
if (this.distributedWatcher) {
await this.distributedWatcher.close();
}
if (this.ownInstance?.data.elected) {
this.ownInstance.data.elected = false;
}
if (this.ownInstance?.data.status === 'stopped') {
@ -225,7 +227,12 @@ export class SmartdataDistributedCoordinator extends plugins.taskbuffer.distribu
this.distributedWatcher.changeSubject.subscribe({
next: async (distributedDoc) => {
console.log(`registered change for distributed doc ${distributedDoc.id}`);
if (!distributedDoc) {
console.log(`registered deletion of instance...`);
return;
}
console.log(distributedDoc);
console.log(`registered change for ${distributedDoc.id}`);
distributedDoc;
},
});

View File

@ -17,9 +17,13 @@ export class SmartdataDbWatcher<T = any> {
smartdataDbDocArg: typeof SmartDataDbDoc
) {
this.changeStream = changeStreamArg;
this.changeStream.on('change', async (item: T) => {
this.changeStream.on('change', async (item: any) => {
if (!item.fullDocument) {
this.changeSubject.next(null);
return;
}
this.changeSubject.next(
smartdataDbDocArg.createInstanceFromMongoDbNativeDoc(item) as any as T
smartdataDbDocArg.createInstanceFromMongoDbNativeDoc(item.fullDocument) as any as T
);
});
plugins.smartdelay.delayFor(0).then(() => {