fix(core): update
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartdata',
|
||||
version: '4.0.28',
|
||||
version: '4.0.29',
|
||||
description: 'do more with data'
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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() {
|
||||
|
@ -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 };
|
||||
|
Reference in New Issue
Block a user