fix(core): update

This commit is contained in:
2022-05-17 21:26:17 +02:00
parent a739582861
commit 355a2a3f2b
10 changed files with 604 additions and 524 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartdata',
version: '4.0.28',
version: '4.0.29',
description: 'do more with data'
}

View File

@ -206,8 +206,12 @@ export class SmartdataCollection<T> {
{
$match: filterObject
}
]);
return new SmartdataDbWatcher(changeStream);
], {
fullDocument: 'updateLookup'
});
const smartdataWatcher = new SmartdataDbWatcher(changeStream);
await smartdataWatcher.readyDeferred.promise;
return smartdataWatcher;
}
/**

View File

@ -5,15 +5,19 @@ import * as plugins from './smartdata.plugins.js';
*/
export class SmartdataDbWatcher<T = any> {
// STATIC
public readyDeferred = plugins.smartpromise.defer();
// INSTANCE
public changeStream: plugins.mongodb.ChangeStream<T>;
public changeSubject = new plugins.smartrx.rxjs.Subject<T>();
constructor(changeStreamArg: plugins.mongodb.ChangeStream<T>) {
this.changeStream = changeStreamArg;
this.changeStream.on('change', (item: T) => {
this.changeStream.on('change', async (item: T) => {
this.changeSubject.next(item);
})
plugins.smartdelay.delayFor(0).then(() => {
this.readyDeferred.resolve();
});
}
public async close() {

View File

@ -7,9 +7,11 @@ export { tsclass };
import * as smartlog from '@pushrocks/smartlog';
import * as lodash from 'lodash';
import * as mongodb from 'mongodb';
import * as smartdelay from '@pushrocks/smartdelay'
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartq from '@pushrocks/smartpromise';
import * as smartrx from '@pushrocks/smartrx';
import * as smartstring from '@pushrocks/smartstring';
import * as smartunique from '@pushrocks/smartunique';
export { smartlog, lodash, smartq, smartrx, mongodb, smartstring, smartunique };
export { smartdelay, smartpromise, smartlog, lodash, smartq, smartrx, mongodb, smartstring, smartunique };