@onehat/data 1.22.8 → 1.22.9
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/package.json +1 -1
- package/src/Repository/Repository.js +23 -0
package/package.json
CHANGED
|
@@ -349,6 +349,7 @@ export default class Repository extends EventEmitter {
|
|
|
349
349
|
|
|
350
350
|
this._createMethods();
|
|
351
351
|
this._createStatics();
|
|
352
|
+
this._createListeners();
|
|
352
353
|
|
|
353
354
|
const init = this.schema.repository.init || this.originalConfig.init; // The latter is mainly for lfr repositories
|
|
354
355
|
if (init) {
|
|
@@ -396,6 +397,28 @@ export default class Repository extends EventEmitter {
|
|
|
396
397
|
}
|
|
397
398
|
}
|
|
398
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Creates the initial listeners for this Repository, based on originalConfig.
|
|
402
|
+
* @private
|
|
403
|
+
*/
|
|
404
|
+
_createListeners() {
|
|
405
|
+
if (this.isDestroyed) {
|
|
406
|
+
this.throwError('this._createListeners is no longer valid. Repository has been destroyed.');
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const listeners = this.originalConfig.listeners;
|
|
410
|
+
if (!_.isEmpty(listeners)) {
|
|
411
|
+
const oThis = this;
|
|
412
|
+
_.each(listeners, ({ event, handler }) => {
|
|
413
|
+
if (!event || !handler) {
|
|
414
|
+
oThis.throwError('Invalid listener definition. Must have event and handler.');
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
oThis.on(event, handler);
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
399
422
|
getModel() {
|
|
400
423
|
if (this.model) {
|
|
401
424
|
return this.model;
|