@arrai-innovations/reactive-helpers 6.0.0 → 7.0.0
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/.vscode/extensions.json +3 -0
- package/package.json +4 -4
- package/use/cancellableIntent.js +4 -0
- package/use/listCalculated.js +16 -5
- package/use/listRelated.js +16 -5
- package/use/objectCalculated.js +15 -3
- package/use/objectRelated.js +12 -2
- package/use/watchesRunning.js +10 -2
- package/utils/debugMessage.js +54 -0
- package/utils/index.js +2 -0
- package/utils/lifecycleDebug.js +52 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrai-innovations/reactive-helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@commitlint/cli": "^16.2.4",
|
|
31
31
|
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
|
32
32
|
"@types/jest": "^27.5.0",
|
|
33
|
-
"@vue/compiler-sfc": "^3.
|
|
33
|
+
"@vue/compiler-sfc": "^3.3.4",
|
|
34
34
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
35
|
-
"@vue/test-utils": "^2.
|
|
35
|
+
"@vue/test-utils": "^2.3.2",
|
|
36
36
|
"@vue/vue3-jest": "^27.0.0",
|
|
37
37
|
"babel-eslint": "^10.1.0",
|
|
38
38
|
"babel-jest": "^27.5.1",
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"lodash-es": "^4.17.21",
|
|
57
|
-
"vue": "^3.
|
|
57
|
+
"vue": "^3.3.4"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/use/cancellableIntent.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { useDebugMessage } from "../utils";
|
|
1
2
|
import identity from "lodash-es/identity";
|
|
2
3
|
import isEqual from "lodash-es/isEqual";
|
|
3
4
|
import { effectScope, nextTick, onScopeDispose, reactive, readonly, watch } from "vue";
|
|
4
5
|
import { deepUnref } from "vue-deepunref";
|
|
5
6
|
|
|
7
|
+
const watchFnDebugMessage = useDebugMessage(["cancellableIntent", "watch"]);
|
|
8
|
+
|
|
6
9
|
/*
|
|
7
10
|
* Calls your awaitable function with the arguments you pass in, when the watch arguments change and are all truthy.
|
|
8
11
|
* Watch arguments should be a reactive object.
|
|
@@ -44,6 +47,7 @@ export function useCancellableIntent({ awaitableWithCancel, watchArguments = {},
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
const watchFn = () => {
|
|
50
|
+
watchFnDebugMessage("watchFn called");
|
|
47
51
|
let newWatchValues = deepUnref(Object.values(watchArguments));
|
|
48
52
|
if (isEqual(newWatchValues, previousWatchValues)) {
|
|
49
53
|
return;
|
package/use/listCalculated.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { keyDiff, loadingCombine } from "../utils";
|
|
1
|
+
import { keyDiff, loadingCombine, useDebugMessage } from "../utils";
|
|
2
2
|
import { listInstanceStateKeys } from "./listInstance";
|
|
3
3
|
import { listRelatedStateKeys } from "./listRelated";
|
|
4
4
|
import { listSubscriptionStateKeys } from "./listSubscription";
|
|
@@ -6,6 +6,9 @@ import { useWatchesRunning } from "./watchesRunning";
|
|
|
6
6
|
import isEmpty from "lodash-es/isEmpty";
|
|
7
7
|
import { computed, effectScope, onScopeDispose, reactive, toRef, watch } from "vue";
|
|
8
8
|
|
|
9
|
+
const computedDebugMessage = useDebugMessage(["listCalculated", "computed"]);
|
|
10
|
+
const watchDebugMessage = useDebugMessage(["listCalculated", "watch"]);
|
|
11
|
+
|
|
9
12
|
export const listCalculatedStateKeys = [
|
|
10
13
|
"calculatedObjects",
|
|
11
14
|
"calculatedObjectsParentStateObjectsWatchRunning",
|
|
@@ -35,6 +38,7 @@ export function useListCalculated({ parentState, calculatedObjectsRules }) {
|
|
|
35
38
|
const calculatedObjectsEffectScopes = {};
|
|
36
39
|
|
|
37
40
|
function parentStateObjectsWatch() {
|
|
41
|
+
watchDebugMessage("parentStateObjectsWatch called");
|
|
38
42
|
const { addedKeys, removedKeys } = keyDiff(
|
|
39
43
|
Object.keys(parentState.objects),
|
|
40
44
|
Object.keys(state.calculatedObjects)
|
|
@@ -53,6 +57,7 @@ export function useListCalculated({ parentState, calculatedObjectsRules }) {
|
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
function calculatedObjectsWatch() {
|
|
60
|
+
watchDebugMessage("calculatedObjectsWatch called");
|
|
56
61
|
const calculatedObjectsRulesIsEmpty = !state.calculatedObjectsRules || isEmpty(state.calculatedObjectsRules);
|
|
57
62
|
for (const objectKey of Object.keys(state.calculatedObjects)) {
|
|
58
63
|
if (!calculatedObjectsEffectScopes[objectKey]) {
|
|
@@ -120,9 +125,12 @@ export function useListCalculated({ parentState, calculatedObjectsRules }) {
|
|
|
120
125
|
|
|
121
126
|
watchesRunning = useWatchesRunning({
|
|
122
127
|
triggerRefs: [
|
|
123
|
-
computed(() =>
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
computed(() => {
|
|
129
|
+
computedDebugMessage("listCalculated trigger");
|
|
130
|
+
return state.calculatedObjectsRules && !isEmpty(state.calculatedObjectsRules)
|
|
131
|
+
? parentState.loading
|
|
132
|
+
: false;
|
|
133
|
+
}),
|
|
126
134
|
],
|
|
127
135
|
watchSentinelRefs: [
|
|
128
136
|
toRef(state, "calculatedObjectsParentStateObjectsWatchRunning"),
|
|
@@ -130,7 +138,10 @@ export function useListCalculated({ parentState, calculatedObjectsRules }) {
|
|
|
130
138
|
],
|
|
131
139
|
});
|
|
132
140
|
|
|
133
|
-
state.running = computed(() =>
|
|
141
|
+
state.running = computed(() => {
|
|
142
|
+
computedDebugMessage("listCalculated running");
|
|
143
|
+
return loadingCombine(watchesRunning.state.running, parentState.running);
|
|
144
|
+
});
|
|
134
145
|
|
|
135
146
|
onScopeDispose(() => {
|
|
136
147
|
for (const objectKey of Object.keys(calculatedObjectsEffectScopes)) {
|
package/use/listRelated.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { keyDiff, loadingCombine } from "../utils";
|
|
1
|
+
import { keyDiff, loadingCombine, useDebugMessage } from "../utils";
|
|
2
2
|
import { listInstanceStateKeys } from "./listInstance";
|
|
3
3
|
import { listSubscriptionStateKeys } from "./listSubscription";
|
|
4
4
|
import { useWatchesRunning } from "./watchesRunning";
|
|
@@ -8,6 +8,9 @@ import isEmpty from "lodash-es/isEmpty";
|
|
|
8
8
|
import isUndefined from "lodash-es/isUndefined";
|
|
9
9
|
import { computed, effectScope, onScopeDispose, reactive, toRef, unref, watch } from "vue";
|
|
10
10
|
|
|
11
|
+
const computedDebugMessage = useDebugMessage(["listRelated", "computed"]);
|
|
12
|
+
const watchDebugMessage = useDebugMessage(["listRelated", "watch"]);
|
|
13
|
+
|
|
11
14
|
export const listRelatedStateKeys = [
|
|
12
15
|
"relatedObjects",
|
|
13
16
|
"relatedObjectsRules",
|
|
@@ -34,6 +37,7 @@ export function useListRelated({ parentState, relatedObjectsRules }) {
|
|
|
34
37
|
const relatedObjectsEffectScopes = {};
|
|
35
38
|
|
|
36
39
|
function parentStateObjectsWatch() {
|
|
40
|
+
watchDebugMessage("parentStateObjectsWatch called");
|
|
37
41
|
const { addedKeys, removedKeys } = keyDiff(Object.keys(parentState.objects), Object.keys(state.relatedObjects));
|
|
38
42
|
for (const removedKey of removedKeys) {
|
|
39
43
|
delete state.relatedObjects[removedKey];
|
|
@@ -49,6 +53,7 @@ export function useListRelated({ parentState, relatedObjectsRules }) {
|
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
function relatedObjectsWatch() {
|
|
56
|
+
watchDebugMessage("relatedObjectsWatch called");
|
|
52
57
|
const relatedObjectsRulesIsEmpty = !state.relatedObjectsRules || isEmpty(state.relatedObjectsRules);
|
|
53
58
|
for (const objectKey of Object.keys(state.relatedObjects)) {
|
|
54
59
|
const relatedObjectsObject = state.relatedObjects[objectKey];
|
|
@@ -120,9 +125,12 @@ export function useListRelated({ parentState, relatedObjectsRules }) {
|
|
|
120
125
|
|
|
121
126
|
watchesRunning = useWatchesRunning({
|
|
122
127
|
triggerRefs: [
|
|
123
|
-
computed(() =>
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
computed(() => {
|
|
129
|
+
computedDebugMessage("listRelated triggerRefs");
|
|
130
|
+
return state.relatedObjectsRules && !isEmpty(state.relatedObjectsRules)
|
|
131
|
+
? parentState.loading
|
|
132
|
+
: false;
|
|
133
|
+
}),
|
|
126
134
|
],
|
|
127
135
|
watchSentinelRefs: [
|
|
128
136
|
toRef(state, "relatedObjectsParentStateObjectsWatchRunning"),
|
|
@@ -130,7 +138,10 @@ export function useListRelated({ parentState, relatedObjectsRules }) {
|
|
|
130
138
|
],
|
|
131
139
|
});
|
|
132
140
|
|
|
133
|
-
state.running = computed(() =>
|
|
141
|
+
state.running = computed(() => {
|
|
142
|
+
computedDebugMessage("listRelated running");
|
|
143
|
+
return loadingCombine(watchesRunning.state.running, parentState.running);
|
|
144
|
+
});
|
|
134
145
|
|
|
135
146
|
onScopeDispose(() => {
|
|
136
147
|
for (const objectKey of Object.keys(relatedObjectsEffectScopes)) {
|
package/use/objectCalculated.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { keyDiff, loadingCombine } from "../utils";
|
|
1
|
+
import { keyDiff, loadingCombine, useDebugMessage } from "../utils";
|
|
2
2
|
import { useWatchesRunning } from "./watchesRunning";
|
|
3
3
|
import isEmpty from "lodash-es/isEmpty";
|
|
4
4
|
import { computed, effectScope, onScopeDispose, reactive, toRef, watch } from "vue";
|
|
5
5
|
|
|
6
|
+
const computedDebugMessage = useDebugMessage(["objectCalculated", "computed"]);
|
|
7
|
+
const watchDebugMessage = useDebugMessage(["objectCalculated", "watch"]);
|
|
8
|
+
|
|
6
9
|
export function useObjectCalculateds(instances, args) {
|
|
7
10
|
for (const [key, value] of Object.entries(args)) {
|
|
8
11
|
useObjectCalculated({
|
|
@@ -65,6 +68,7 @@ export function useObjectCalculated({
|
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
watch([() => state.calculatedObjectRules && Object.keys(state.calculatedObjectRules)], () => {
|
|
71
|
+
watchDebugMessage("calculatedObjectRules watch called");
|
|
68
72
|
let addedKeys = [],
|
|
69
73
|
removedKeys = [],
|
|
70
74
|
sameKeys = [];
|
|
@@ -102,7 +106,12 @@ export function useObjectCalculated({
|
|
|
102
106
|
});
|
|
103
107
|
|
|
104
108
|
watchesRunning = useWatchesRunning({
|
|
105
|
-
triggerRefs: [
|
|
109
|
+
triggerRefs: [
|
|
110
|
+
computed(() => {
|
|
111
|
+
computedDebugMessage("watchesRunningTriggerRefs computed");
|
|
112
|
+
return !isEmpty(state.calculatedObjectRules) ? parentState.loading : false;
|
|
113
|
+
}),
|
|
114
|
+
],
|
|
106
115
|
watchSentinelRefs: [
|
|
107
116
|
toRef(state, "parentStateObjectWatchRunning"),
|
|
108
117
|
toRef(state, "calculatedObjectWatchRunning"),
|
|
@@ -110,7 +119,10 @@ export function useObjectCalculated({
|
|
|
110
119
|
});
|
|
111
120
|
|
|
112
121
|
state.calculatedRunning = toRef(watchesRunning.state, "running");
|
|
113
|
-
state.running = computed(() =>
|
|
122
|
+
state.running = computed(() => {
|
|
123
|
+
computedDebugMessage("running computed");
|
|
124
|
+
return loadingCombine(watchesRunning.state.running, parentState.relatedRunning);
|
|
125
|
+
});
|
|
114
126
|
|
|
115
127
|
onScopeDispose(() => {
|
|
116
128
|
for (const key in calculatedObjectEffectScopes) {
|
package/use/objectRelated.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { keyDiff } from "../utils";
|
|
1
|
+
import { keyDiff, useDebugMessage } from "../utils";
|
|
2
2
|
import { useWatchesRunning } from "./watchesRunning";
|
|
3
3
|
import get from "lodash-es/get";
|
|
4
4
|
import isArray from "lodash-es/isArray";
|
|
@@ -6,6 +6,9 @@ import isEmpty from "lodash-es/isEmpty";
|
|
|
6
6
|
import isUndefined from "lodash-es/isUndefined";
|
|
7
7
|
import { computed, effectScope, onScopeDispose, reactive, toRef, unref, watch } from "vue";
|
|
8
8
|
|
|
9
|
+
const computedDebugMessage = useDebugMessage(["objectRelated", "computed"]);
|
|
10
|
+
const watchDebugMessage = useDebugMessage(["objectRelated", "watch"]);
|
|
11
|
+
|
|
9
12
|
export function useObjectRelateds(instances, args) {
|
|
10
13
|
for (const [key, value] of Object.entries(args)) {
|
|
11
14
|
useObjectRelated({
|
|
@@ -61,6 +64,7 @@ export function useObjectRelated({
|
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
watch([() => state.relatedObjectRules && Object.keys(state.relatedObjectRules)], () => {
|
|
67
|
+
watchDebugMessage("relatedObjectRules changed");
|
|
64
68
|
let addedRuleKeys = [],
|
|
65
69
|
removedRuleKeys = [];
|
|
66
70
|
if (!state.relatedObjectRules) {
|
|
@@ -83,6 +87,7 @@ export function useObjectRelated({
|
|
|
83
87
|
relatedObjectEffectScopes[addedRuleKey] = effectScope();
|
|
84
88
|
relatedObjectEffectScopes[addedRuleKey].run(() => {
|
|
85
89
|
state.relatedObjectObjects[addedRuleKey] = computed(() => {
|
|
90
|
+
computedDebugMessage("relatedObjectObjects computed");
|
|
86
91
|
// deal with computed objects being passed.
|
|
87
92
|
const ruleObjects = unref(state.relatedObjectRules?.[addedRuleKey]?.objects);
|
|
88
93
|
const rulePkKey = state.relatedObjectRules?.[addedRuleKey]?.pkKey || addedRuleKey;
|
|
@@ -103,7 +108,12 @@ export function useObjectRelated({
|
|
|
103
108
|
});
|
|
104
109
|
|
|
105
110
|
watchesRunning = useWatchesRunning({
|
|
106
|
-
triggerRefs: [
|
|
111
|
+
triggerRefs: [
|
|
112
|
+
computed(() => {
|
|
113
|
+
watchDebugMessage("parentStateObjectWatchRunning");
|
|
114
|
+
return !isEmpty(state.relatedObjectRules) ? parentState.loading : false;
|
|
115
|
+
}),
|
|
116
|
+
],
|
|
107
117
|
watchSentinelRefs: [
|
|
108
118
|
toRef(state, "parentStateObjectWatchRunning"),
|
|
109
119
|
toRef(state, "relatedObjectWatchRunning"),
|
package/use/watchesRunning.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { loadingCombine } from "../utils";
|
|
1
|
+
import { loadingCombine, useDebugMessage } from "../utils";
|
|
2
2
|
import { computed, effectScope, reactive, unref, watch } from "vue";
|
|
3
3
|
|
|
4
|
+
const computedDebugMessage = useDebugMessage(["watchesRunning", "computed"]);
|
|
5
|
+
const watchDebugMessage = useDebugMessage(["watchesRunning", "watch"]);
|
|
6
|
+
|
|
4
7
|
export function useWatchesRunning({ triggerRefs, watchSentinelRefs }) {
|
|
5
8
|
const state = reactive({});
|
|
6
9
|
|
|
@@ -10,6 +13,7 @@ export function useWatchesRunning({ triggerRefs, watchSentinelRefs }) {
|
|
|
10
13
|
watch(
|
|
11
14
|
triggerRefs,
|
|
12
15
|
(values) => {
|
|
16
|
+
watchDebugMessage("useWatchesRunning triggerRefs");
|
|
13
17
|
if (values.every((value) => unref(value))) {
|
|
14
18
|
watchSentinelRefs.forEach((ref) => {
|
|
15
19
|
ref.value = true;
|
|
@@ -21,7 +25,11 @@ export function useWatchesRunning({ triggerRefs, watchSentinelRefs }) {
|
|
|
21
25
|
deep: true,
|
|
22
26
|
}
|
|
23
27
|
);
|
|
24
|
-
state.running = computed(() =>
|
|
28
|
+
state.running = computed(() => {
|
|
29
|
+
const values = watchSentinelRefs.map((ref) => ref.value);
|
|
30
|
+
computedDebugMessage("useWatchesRunning running");
|
|
31
|
+
return loadingCombine(values);
|
|
32
|
+
});
|
|
25
33
|
});
|
|
26
34
|
|
|
27
35
|
return {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import inspect from "browser-util-inspect";
|
|
2
|
+
import { unref } from "vue";
|
|
3
|
+
|
|
4
|
+
window.RH_DEBUG = false;
|
|
5
|
+
window.RH_DEBUG_ENABLED_CATEGORIES = {};
|
|
6
|
+
window.RH_DEBUG_DISABLED_CATEGORIES = {};
|
|
7
|
+
|
|
8
|
+
const log = console.log;
|
|
9
|
+
const messageHolder = [];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {String} categoriesString
|
|
13
|
+
* @param {(string|Function)[]} messages
|
|
14
|
+
*/
|
|
15
|
+
const doLog = (categoriesString, messages) => {
|
|
16
|
+
if (messages.length > 0) {
|
|
17
|
+
for (const message of messages) {
|
|
18
|
+
messageHolder.push(inspect(unref(typeof message === "function" ? message() : message)));
|
|
19
|
+
}
|
|
20
|
+
log(categoriesString, ...messageHolder);
|
|
21
|
+
messageHolder.length = 0;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {string[]} categories
|
|
28
|
+
* @returns {function(...((string|Function)[]|string|Function)): void}
|
|
29
|
+
*/
|
|
30
|
+
export function useDebugMessage(categories) {
|
|
31
|
+
const categoriesSet = new Set(categories);
|
|
32
|
+
const categoriesString = categoriesSet.size > 0 ? `[${Array.from(categoriesSet).join(", ")}]` : "";
|
|
33
|
+
return (...messages) => {
|
|
34
|
+
if (!window.RH_DEBUG) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (categoriesSet.size > 0) {
|
|
38
|
+
for (const category of categoriesSet) {
|
|
39
|
+
if (window.RH_DEBUG_DISABLED_CATEGORIES[category]) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
for (const category of categoriesSet) {
|
|
44
|
+
if (window.RH_DEBUG_ENABLED_CATEGORIES[category]) {
|
|
45
|
+
doLog(categoriesString, messages);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (categoriesSet.size === 0 || Object.keys(window.RH_DEBUG_ENABLED_CATEGORIES).length === 0) {
|
|
51
|
+
doLog(categoriesString, messages);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
package/utils/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from "./assignReactiveObject";
|
|
2
|
+
export * from "./debugMessage";
|
|
2
3
|
export * from "./debugWatch";
|
|
3
4
|
export * from "./flattenPaths";
|
|
4
5
|
export * from "./getFakeId";
|
|
5
6
|
export * from "./keyDiff";
|
|
7
|
+
export * from "./lifecycleDebug";
|
|
6
8
|
export * from "./loadingCombine";
|
|
7
9
|
export * from "./set";
|
|
8
10
|
export * from "./watches";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useDebugMessage } from "./debugMessage";
|
|
2
|
+
import {
|
|
3
|
+
onActivated,
|
|
4
|
+
onBeforeMount,
|
|
5
|
+
onBeforeUnmount,
|
|
6
|
+
onBeforeUpdate,
|
|
7
|
+
onDeactivated,
|
|
8
|
+
onErrorCaptured,
|
|
9
|
+
onMounted,
|
|
10
|
+
onRenderTracked,
|
|
11
|
+
onRenderTriggered,
|
|
12
|
+
onServerPrefetch,
|
|
13
|
+
onUnmounted,
|
|
14
|
+
onUpdated,
|
|
15
|
+
} from "vue";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {string[]} categories
|
|
19
|
+
*/
|
|
20
|
+
export function useLifecycleDebug(categories, includes = [], excludes = []) {
|
|
21
|
+
const lifeCycleFns = {
|
|
22
|
+
onActivated,
|
|
23
|
+
onBeforeMount,
|
|
24
|
+
onBeforeUnmount,
|
|
25
|
+
onBeforeUpdate,
|
|
26
|
+
onDeactivated,
|
|
27
|
+
onErrorCaptured,
|
|
28
|
+
onMounted,
|
|
29
|
+
onRenderTracked,
|
|
30
|
+
onRenderTriggered,
|
|
31
|
+
onServerPrefetch,
|
|
32
|
+
onUnmounted,
|
|
33
|
+
onUpdated,
|
|
34
|
+
};
|
|
35
|
+
const hasIncludes = includes && includes.length > 0;
|
|
36
|
+
const hasExcludes = excludes && excludes.length > 0;
|
|
37
|
+
for (const key in lifeCycleFns) {
|
|
38
|
+
if (hasIncludes && !includes.includes(key)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (hasExcludes && excludes.includes(key)) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const myCategories = new Set(categories);
|
|
45
|
+
myCategories.add(key);
|
|
46
|
+
const eventString = `${key} called`;
|
|
47
|
+
const debugMessage = useDebugMessage(myCategories);
|
|
48
|
+
lifeCycleFns[key](() => {
|
|
49
|
+
debugMessage(eventString);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|