owservable 0.8.39 → 0.8.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_enums/store.type.enum.d.ts +6 -6
- package/lib/_enums/store.type.enum.js +9 -9
- package/lib/_types/connection.manager.refresh.type.d.ts +9 -9
- package/lib/_types/connection.manager.refresh.type.js +2 -2
- package/lib/_types/cronjob.type.d.ts +7 -7
- package/lib/_types/cronjob.type.js +2 -2
- package/lib/_types/store.scope.type.d.ts +2 -2
- package/lib/_types/store.scope.type.js +2 -2
- package/lib/_types/store.subscription.config.type.d.ts +15 -15
- package/lib/_types/store.subscription.config.type.js +2 -2
- package/lib/_types/store.subscription.update.type.d.ts +9 -9
- package/lib/_types/store.subscription.update.type.js +2 -2
- package/lib/_types/subscription.methods.type.d.ts +6 -6
- package/lib/_types/subscription.methods.type.js +2 -2
- package/lib/_types/watcher.type.d.ts +6 -5
- package/lib/_types/watcher.type.js +2 -2
- package/lib/_types/worker.type.d.ts +5 -5
- package/lib/_types/worker.type.js +2 -2
- package/lib/auth/i.connection.manager.d.ts +9 -9
- package/lib/auth/i.connection.manager.js +2 -2
- package/lib/functions/action/add.action.cronjobs.d.ts +1 -1
- package/lib/functions/action/add.action.cronjobs.js +25 -25
- package/lib/functions/action/add.action.watchers.d.ts +1 -1
- package/lib/functions/action/add.action.watchers.js +22 -22
- package/lib/functions/action/add.action.workers.d.ts +1 -1
- package/lib/functions/action/add.action.workers.js +22 -22
- package/lib/functions/execute/execute.cronjob.d.ts +3 -3
- package/lib/functions/execute/execute.cronjob.js +12 -12
- package/lib/functions/execute/execute.on.files.recursively.d.ts +2 -2
- package/lib/functions/execute/execute.on.files.recursively.js +17 -17
- package/lib/functions/execute/execute.processes.in.folder.d.ts +2 -2
- package/lib/functions/execute/execute.processes.in.folder.js +10 -10
- package/lib/functions/execute/execute.watcher.d.ts +3 -3
- package/lib/functions/execute/execute.watcher.js +16 -11
- package/lib/functions/execute/execute.watcher.js.map +1 -1
- package/lib/functions/execute/execute.worker.d.ts +3 -3
- package/lib/functions/execute/execute.worker.js +11 -11
- package/lib/functions/initiate.cronjobs.d.ts +2 -2
- package/lib/functions/initiate.cronjobs.js +8 -8
- package/lib/functions/initiate.watchers.d.ts +2 -2
- package/lib/functions/initiate.watchers.js +8 -8
- package/lib/functions/initiate.workers.d.ts +2 -2
- package/lib/functions/initiate.workers.js +8 -8
- package/lib/middleware/data.middleware.map.d.ts +7 -7
- package/lib/middleware/data.middleware.map.js +18 -18
- package/lib/middleware/data.middleware.map.js.map +1 -1
- package/lib/mongodb/collections.models.map.d.ts +8 -8
- package/lib/mongodb/collections.models.map.js +22 -22
- package/lib/mongodb/collections.models.map.js.map +1 -1
- package/lib/mongodb/functions/index/add.both.indices.to.attributes.d.ts +3 -3
- package/lib/mongodb/functions/index/add.both.indices.to.attributes.js +8 -8
- package/lib/mongodb/functions/index/add.down.indices.to.attributes.d.ts +3 -3
- package/lib/mongodb/functions/index/add.down.indices.to.attributes.js +5 -5
- package/lib/mongodb/functions/index/add.index.to.attributes.d.ts +3 -3
- package/lib/mongodb/functions/index/add.index.to.attributes.js +11 -11
- package/lib/mongodb/functions/index/add.up.and.down.indices.to.attributes.d.ts +3 -3
- package/lib/mongodb/functions/index/add.up.and.down.indices.to.attributes.js +9 -9
- package/lib/mongodb/functions/index/add.up.indices.to.attributes.d.ts +3 -3
- package/lib/mongodb/functions/index/add.up.indices.to.attributes.js +5 -5
- package/lib/mongodb/functions/observable.database.d.ts +3 -3
- package/lib/mongodb/functions/observable.database.js +22 -22
- package/lib/mongodb/functions/observable.model.d.ts +4 -4
- package/lib/mongodb/functions/observable.model.js +41 -41
- package/lib/mongodb/functions/process.models.d.ts +2 -2
- package/lib/mongodb/functions/process.models.js +40 -40
- package/lib/mongodb/mongodb.connector.d.ts +7 -7
- package/lib/mongodb/mongodb.connector.js +51 -51
- package/lib/owservable.client.d.ts +23 -23
- package/lib/owservable.client.js +162 -162
- package/lib/owservable.d.ts +41 -41
- package/lib/owservable.js +63 -63
- package/lib/store/a.store.d.ts +37 -37
- package/lib/store/a.store.js +126 -126
- package/lib/store/collection.store.d.ts +8 -8
- package/lib/store/collection.store.js +111 -112
- package/lib/store/collection.store.js.map +1 -1
- package/lib/store/count.store.d.ts +7 -7
- package/lib/store/count.store.js +46 -46
- package/lib/store/document.store.d.ts +12 -12
- package/lib/store/document.store.js +134 -135
- package/lib/store/document.store.js.map +1 -1
- package/lib/store/factories/store.factory.d.ts +4 -4
- package/lib/store/factories/store.factory.js +15 -15
- package/package.json +8 -8
|
@@ -1,113 +1,112 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const sift_1 = require("sift");
|
|
13
|
-
const _ = require("lodash");
|
|
14
|
-
const a_store_1 = require("./a.store");
|
|
15
|
-
const store_type_enum_1 = require("../_enums/store.type.enum");
|
|
16
|
-
class CollectionStore extends a_store_1.default {
|
|
17
|
-
constructor(model, target) {
|
|
18
|
-
super(model, target);
|
|
19
|
-
this._type = store_type_enum_1.default.COLLECTION;
|
|
20
|
-
Object.setPrototypeOf(this, CollectionStore.prototype);
|
|
21
|
-
}
|
|
22
|
-
shouldReload(change) {
|
|
23
|
-
if (this.isInitialSubscription(change))
|
|
24
|
-
return true;
|
|
25
|
-
const { operationType: type, updateDescription: description, fullDocument: document } = change;
|
|
26
|
-
const test = (0, sift_1.default)(_.omit(this._query, ['createdAt', 'updatedAt']));
|
|
27
|
-
switch (type) {
|
|
28
|
-
case 'delete':
|
|
29
|
-
case 'insert':
|
|
30
|
-
return true;
|
|
31
|
-
case 'replace':
|
|
32
|
-
case 'update':
|
|
33
|
-
if (!description)
|
|
34
|
-
return true;
|
|
35
|
-
if (!this.shouldConsiderFields())
|
|
36
|
-
return test(document);
|
|
37
|
-
const { updatedFields, removedFields } = description;
|
|
38
|
-
const us = _.concat(removedFields, _.keys(updatedFields));
|
|
39
|
-
const qs = _.keys(this._fields);
|
|
40
|
-
return !_.isEmpty(_.intersection(qs, us));
|
|
41
|
-
}
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
load(change) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
if (_.isEmpty(this._config))
|
|
47
|
-
return this.emitMany();
|
|
48
|
-
if (!this.shouldReload(change))
|
|
49
|
-
return;
|
|
50
|
-
try {
|
|
51
|
-
const { operationType: type, documentKey, fullDocument: document } = change;
|
|
52
|
-
const key = _.get(documentKey, '_id', '').toString();
|
|
53
|
-
if (document && this._incremental) {
|
|
54
|
-
if ('delete' === type)
|
|
55
|
-
return this.emitDelete(key);
|
|
56
|
-
for (const populate of this._populates) {
|
|
57
|
-
yield this._model.populate(document, populate);
|
|
58
|
-
}
|
|
59
|
-
if (_.isEmpty(this._virtuals))
|
|
60
|
-
return this.emitMany({ data: document });
|
|
61
|
-
const replacement = _.cloneDeep(_.omit(document.toJSON(), this._virtuals));
|
|
62
|
-
for (const virtual of this._virtuals) {
|
|
63
|
-
replacement[virtual] = yield Promise.resolve(document[virtual]);
|
|
64
|
-
}
|
|
65
|
-
return this.emitMany({ data: replacement });
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
let data = [];
|
|
69
|
-
const total = yield this._model.countDocuments(this._query);
|
|
70
|
-
if (total > 0) {
|
|
71
|
-
data = yield this._model
|
|
72
|
-
.find(this._query, this._fields, this._paging)
|
|
73
|
-
.
|
|
74
|
-
.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
exports.default = CollectionStore;
|
|
1
|
+
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const sift_1 = require("sift");
|
|
13
|
+
const _ = require("lodash");
|
|
14
|
+
const a_store_1 = require("./a.store");
|
|
15
|
+
const store_type_enum_1 = require("../_enums/store.type.enum");
|
|
16
|
+
class CollectionStore extends a_store_1.default {
|
|
17
|
+
constructor(model, target) {
|
|
18
|
+
super(model, target);
|
|
19
|
+
this._type = store_type_enum_1.default.COLLECTION;
|
|
20
|
+
Object.setPrototypeOf(this, CollectionStore.prototype);
|
|
21
|
+
}
|
|
22
|
+
shouldReload(change) {
|
|
23
|
+
if (this.isInitialSubscription(change))
|
|
24
|
+
return true;
|
|
25
|
+
const { operationType: type, updateDescription: description, fullDocument: document } = change;
|
|
26
|
+
const test = (0, sift_1.default)(_.omit(this._query, ['createdAt', 'updatedAt']));
|
|
27
|
+
switch (type) {
|
|
28
|
+
case 'delete':
|
|
29
|
+
case 'insert':
|
|
30
|
+
return true;
|
|
31
|
+
case 'replace':
|
|
32
|
+
case 'update':
|
|
33
|
+
if (!description)
|
|
34
|
+
return true;
|
|
35
|
+
if (!this.shouldConsiderFields())
|
|
36
|
+
return test(document);
|
|
37
|
+
const { updatedFields, removedFields } = description;
|
|
38
|
+
const us = _.concat(removedFields, _.keys(updatedFields));
|
|
39
|
+
const qs = _.keys(this._fields);
|
|
40
|
+
return !_.isEmpty(_.intersection(qs, us));
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
load(change) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
if (_.isEmpty(this._config))
|
|
47
|
+
return this.emitMany();
|
|
48
|
+
if (!this.shouldReload(change))
|
|
49
|
+
return;
|
|
50
|
+
try {
|
|
51
|
+
const { operationType: type, documentKey, fullDocument: document } = change;
|
|
52
|
+
const key = _.get(documentKey, '_id', '').toString();
|
|
53
|
+
if (document && this._incremental) {
|
|
54
|
+
if ('delete' === type)
|
|
55
|
+
return this.emitDelete(key);
|
|
56
|
+
for (const populate of this._populates) {
|
|
57
|
+
yield this._model.populate(document, populate);
|
|
58
|
+
}
|
|
59
|
+
if (_.isEmpty(this._virtuals))
|
|
60
|
+
return this.emitMany({ data: document });
|
|
61
|
+
const replacement = _.cloneDeep(_.omit(document.toJSON(), this._virtuals));
|
|
62
|
+
for (const virtual of this._virtuals) {
|
|
63
|
+
replacement[virtual] = yield Promise.resolve(document[virtual]);
|
|
64
|
+
}
|
|
65
|
+
return this.emitMany({ data: replacement });
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
let data = [];
|
|
69
|
+
const total = yield this._model.countDocuments(this._query);
|
|
70
|
+
if (total > 0) {
|
|
71
|
+
data = yield this._model
|
|
72
|
+
.find(this._query, this._fields, this._paging)
|
|
73
|
+
.sort(this._sort)
|
|
74
|
+
.setOptions({ allowDiskUse: true });
|
|
75
|
+
for (const populate of this._populates) {
|
|
76
|
+
yield this._model.populate(data, populate);
|
|
77
|
+
}
|
|
78
|
+
if (!_.isEmpty(this._virtuals)) {
|
|
79
|
+
const replacements = [];
|
|
80
|
+
for (const item of data) {
|
|
81
|
+
const replacement = _.cloneDeep(_.omit(item.toJSON(), this._virtuals));
|
|
82
|
+
for (const virtual of this._virtuals) {
|
|
83
|
+
replacement[virtual] = yield Promise.resolve(item[virtual]);
|
|
84
|
+
}
|
|
85
|
+
replacements.push(replacement);
|
|
86
|
+
}
|
|
87
|
+
data = replacements;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return this.emitMany({ total, data });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
this.emitError(error);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
extractFromConfig() {
|
|
99
|
+
super.extractFromConfig();
|
|
100
|
+
const { incremental = false, page = 1, pageSize } = this._config;
|
|
101
|
+
this._incremental = incremental;
|
|
102
|
+
this._paging = {};
|
|
103
|
+
if (pageSize) {
|
|
104
|
+
this._paging = {
|
|
105
|
+
skip: (page - 1) * pageSize,
|
|
106
|
+
limit: pageSize
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.default = CollectionStore;
|
|
113
112
|
//# sourceMappingURL=collection.store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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EAAE,QAAQ;aACf,CAAC;SACF;IACF,CAAC;CACD;AAxGD,kCAwGC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Model } from 'mongoose';
|
|
2
|
-
import AStore from './a.store';
|
|
3
|
-
export default class CountStore extends AStore {
|
|
4
|
-
constructor(model: Model<any>, target: string);
|
|
5
|
-
protected shouldReload(change: any): boolean;
|
|
6
|
-
protected load(change: any): Promise<void>;
|
|
7
|
-
}
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import AStore from './a.store';
|
|
3
|
+
export default class CountStore extends AStore {
|
|
4
|
+
constructor(model: Model<any>, target: string);
|
|
5
|
+
protected shouldReload(change: any): boolean;
|
|
6
|
+
protected load(change: any): Promise<void>;
|
|
7
|
+
}
|
package/lib/store/count.store.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const lodash_1 = require("lodash");
|
|
13
|
-
const a_store_1 = require("./a.store");
|
|
14
|
-
const store_type_enum_1 = require("../_enums/store.type.enum");
|
|
15
|
-
class CountStore extends a_store_1.default {
|
|
16
|
-
constructor(model, target) {
|
|
17
|
-
super(model, target);
|
|
18
|
-
this._type = store_type_enum_1.default.COUNT;
|
|
19
|
-
Object.setPrototypeOf(this, CountStore.prototype);
|
|
20
|
-
}
|
|
21
|
-
shouldReload(change) {
|
|
22
|
-
if (this.isInitialSubscription(change))
|
|
23
|
-
return true;
|
|
24
|
-
const { operationType: type } = change;
|
|
25
|
-
switch (type) {
|
|
26
|
-
case 'delete':
|
|
27
|
-
case 'insert':
|
|
28
|
-
return true;
|
|
29
|
-
case 'replace':
|
|
30
|
-
case 'update':
|
|
31
|
-
default:
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
load(change) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
if ((0, lodash_1.isEmpty)(this._config))
|
|
38
|
-
return this.emitOne();
|
|
39
|
-
if (!this.shouldReload(change))
|
|
40
|
-
return;
|
|
41
|
-
const count = yield this._model.countDocuments(this._query);
|
|
42
|
-
this.emitOne(count);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.default = CountStore;
|
|
1
|
+
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const lodash_1 = require("lodash");
|
|
13
|
+
const a_store_1 = require("./a.store");
|
|
14
|
+
const store_type_enum_1 = require("../_enums/store.type.enum");
|
|
15
|
+
class CountStore extends a_store_1.default {
|
|
16
|
+
constructor(model, target) {
|
|
17
|
+
super(model, target);
|
|
18
|
+
this._type = store_type_enum_1.default.COUNT;
|
|
19
|
+
Object.setPrototypeOf(this, CountStore.prototype);
|
|
20
|
+
}
|
|
21
|
+
shouldReload(change) {
|
|
22
|
+
if (this.isInitialSubscription(change))
|
|
23
|
+
return true;
|
|
24
|
+
const { operationType: type } = change;
|
|
25
|
+
switch (type) {
|
|
26
|
+
case 'delete':
|
|
27
|
+
case 'insert':
|
|
28
|
+
return true;
|
|
29
|
+
case 'replace':
|
|
30
|
+
case 'update':
|
|
31
|
+
default:
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
load(change) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
if ((0, lodash_1.isEmpty)(this._config))
|
|
38
|
+
return this.emitOne();
|
|
39
|
+
if (!this.shouldReload(change))
|
|
40
|
+
return;
|
|
41
|
+
const count = yield this._model.countDocuments(this._query);
|
|
42
|
+
this.emitOne(count);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = CountStore;
|
|
47
47
|
//# sourceMappingURL=count.store.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import AStore from './a.store';
|
|
2
|
-
export default class DocumentStore extends AStore {
|
|
3
|
-
constructor(model: any, target: string);
|
|
4
|
-
protected extractFromConfig(): void;
|
|
5
|
-
restartSubscription(): void;
|
|
6
|
-
protected shouldReload(change: any): boolean;
|
|
7
|
-
protected load(change: any): Promise<void>;
|
|
8
|
-
private _pipeFilter;
|
|
9
|
-
private _loadDocumentById;
|
|
10
|
-
private _loadSortedFirstDocument;
|
|
11
|
-
private _loadDocument;
|
|
12
|
-
}
|
|
1
|
+
import AStore from './a.store';
|
|
2
|
+
export default class DocumentStore extends AStore {
|
|
3
|
+
constructor(model: any, target: string);
|
|
4
|
+
protected extractFromConfig(): void;
|
|
5
|
+
restartSubscription(): void;
|
|
6
|
+
protected shouldReload(change: any): boolean;
|
|
7
|
+
protected load(change: any): Promise<void>;
|
|
8
|
+
private _pipeFilter;
|
|
9
|
+
private _loadDocumentById;
|
|
10
|
+
private _loadSortedFirstDocument;
|
|
11
|
+
private _loadDocument;
|
|
12
|
+
}
|