1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.lifeCycleObserver = exports.lifeCycleObserverFilter = exports.asLifeCycleObserver = exports.isLifeCycleObserverClass = exports.isLifeCycleObserver = void 0;
|
8 | const context_1 = require("@loopback/context");
|
9 | const keys_1 = require("./keys");
|
10 | const lifeCycleMethods = ['init', 'start', 'stop'];
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function isLifeCycleObserver(obj) {
|
16 | const candidate = obj;
|
17 | return lifeCycleMethods.some(m => typeof candidate[m] === 'function');
|
18 | }
|
19 | exports.isLifeCycleObserver = isLifeCycleObserver;
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function isLifeCycleObserverClass(ctor) {
|
25 | return ctor.prototype && isLifeCycleObserver(ctor.prototype);
|
26 | }
|
27 | exports.isLifeCycleObserverClass = isLifeCycleObserverClass;
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | function asLifeCycleObserver(binding) {
|
35 | return binding.tag(keys_1.CoreTags.LIFE_CYCLE_OBSERVER);
|
36 | }
|
37 | exports.asLifeCycleObserver = asLifeCycleObserver;
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | exports.lifeCycleObserverFilter = (0, context_1.filterByTag)(keys_1.CoreTags.LIFE_CYCLE_OBSERVER);
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | function lifeCycleObserver(group = '', ...specs) {
|
49 | return (0, context_1.injectable)(asLifeCycleObserver, {
|
50 | tags: {
|
51 | [keys_1.CoreTags.LIFE_CYCLE_OBSERVER_GROUP]: group,
|
52 | },
|
53 | }, ...specs);
|
54 | }
|
55 | exports.lifeCycleObserver = lifeCycleObserver;
|
56 |
|
\ | No newline at end of file |