@mic-rexjs/usecases-react 3.7.0 → 4.0.0-beta.3
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/dist/index.min.js +1 -1
- package/dist/index.min.js.LICENSE.txt +2 -0
- package/es/components/UseCaseFragment/index.js +2 -2
- package/es/enums/Statuses/index.d.ts +86 -10
- package/es/enums/Statuses/index.js +86 -10
- package/es/hooks/useAlternateStatuses/index.d.ts +2 -0
- package/es/hooks/useAlternateStatuses/index.js +16 -0
- package/es/hooks/useChanged/index.d.ts +2 -0
- package/es/hooks/useChanged/index.js +17 -0
- package/es/hooks/useChanged/types.d.ts +3 -0
- package/es/hooks/useContext/index.d.ts +3 -4
- package/es/hooks/useContext/index.js +17 -15
- package/es/hooks/useContext/index.test.js +13 -24
- package/es/hooks/useContextValue/index.d.ts +5 -0
- package/es/hooks/useContextValue/index.js +13 -0
- package/es/hooks/useDepsKey/index.js +11 -9
- package/es/hooks/useEntity/index.d.ts +3 -2
- package/es/hooks/useEntity/index.js +52 -53
- package/es/hooks/useEntityReturn/index.d.ts +5 -0
- package/es/hooks/useEntityReturn/index.js +15 -0
- package/es/hooks/useEntityReturn/types.d.ts +7 -0
- package/es/hooks/useEntityRootExec/index.d.ts +5 -0
- package/es/hooks/useEntityRootExec/index.js +7 -0
- package/es/hooks/useEntityRootExec/types.d.ts +7 -0
- package/es/hooks/useEntityRootExec/types.js +1 -0
- package/es/hooks/useEntityRootReturn/index.d.ts +5 -0
- package/es/hooks/useEntityRootReturn/index.js +14 -0
- package/es/hooks/useEntityRootReturn/types.d.ts +7 -0
- package/es/hooks/useEntityRootReturn/types.js +1 -0
- package/es/hooks/useExec/index.d.ts +2 -3
- package/es/hooks/useExec/index.js +3 -12
- package/es/hooks/useExec/types.d.ts +10 -2
- package/es/hooks/useFullArguments/index.d.ts +2 -3
- package/es/hooks/useFullArguments/index.js +4 -6
- package/es/hooks/useFullArguments/types.d.ts +2 -2
- package/es/hooks/useIfExec/index.d.ts +2 -0
- package/es/hooks/useIfExec/index.js +20 -0
- package/es/hooks/useIfExec/types.d.ts +6 -0
- package/es/hooks/useIfExec/types.js +1 -0
- package/es/hooks/useIfReturn/index.d.ts +2 -0
- package/es/hooks/useIfReturn/index.js +22 -0
- package/es/hooks/useIfReturn/types.d.ts +6 -0
- package/es/hooks/useIfReturn/types.js +1 -0
- package/es/hooks/useProvider/index.d.ts +3 -5
- package/es/hooks/useProvider/index.js +17 -23
- package/es/hooks/useProviders/index.js +4 -4
- package/es/hooks/useReducers/index.d.ts +5 -4
- package/es/hooks/useReducers/index.js +45 -27
- package/es/hooks/useReturn/index.d.ts +2 -0
- package/es/hooks/useReturn/index.js +33 -0
- package/es/hooks/useReturn/types.d.ts +11 -0
- package/es/hooks/useReturn/types.js +1 -0
- package/es/hooks/useRootInitializing/index.d.ts +2 -0
- package/es/hooks/useRootInitializing/index.js +14 -0
- package/es/hooks/useRootReturn/index.d.ts +5 -0
- package/es/hooks/useRootReturn/index.js +22 -0
- package/es/hooks/useRootReturn/types.d.ts +14 -0
- package/es/hooks/useRootReturn/types.js +1 -0
- package/es/hooks/useStatuses/index.d.ts +4 -4
- package/es/hooks/useStatuses/index.js +46 -21
- package/es/hooks/useStore/index.d.ts +3 -3
- package/es/hooks/useStore/index.js +21 -49
- package/es/hooks/useThrottleUpdate/index.d.ts +2 -0
- package/es/hooks/useThrottleUpdate/index.js +31 -0
- package/es/hooks/useThrottleUpdate/types.d.ts +3 -0
- package/es/hooks/useThrottleUpdate/types.js +1 -0
- package/es/hooks/useUseCase/index.js +21 -24
- package/es/hooks/useUseCase/index.test.js +330 -98
- package/es/hooks/useUseCase/types.d.ts +15 -5
- package/es/methods/cacheCall/index.d.ts +2 -0
- package/es/methods/cacheCall/index.js +38 -0
- package/es/methods/cacheCall/types.d.ts +12 -0
- package/es/methods/cacheCall/types.js +1 -0
- package/es/methods/cacheCalls/index.d.ts +2 -0
- package/es/methods/cacheCalls/index.js +12 -0
- package/es/types.d.ts +2 -1
- package/es/usecases/contextUseCase/index.js +21 -38
- package/es/usecases/contextUseCase/types.d.ts +5 -6
- package/es/usecases/lifecycleEventUseCase/index.js +37 -9
- package/es/usecases/lifecycleEventUseCase/types.d.ts +11 -8
- package/lib/components/UseCaseFragment/index.js +2 -2
- package/lib/enums/Statuses/index.js +86 -10
- package/lib/hooks/useAlternateStatuses/index.js +22 -0
- package/lib/hooks/useChanged/index.js +23 -0
- package/lib/hooks/useContext/index.js +19 -17
- package/lib/hooks/useContext/index.test.js +13 -24
- package/lib/hooks/useContextValue/index.js +19 -0
- package/lib/hooks/useDepsKey/index.js +10 -8
- package/lib/hooks/useEntity/index.js +81 -54
- package/lib/hooks/useEntityReturn/index.js +22 -0
- package/lib/hooks/useEntityRootExec/index.js +13 -0
- package/lib/hooks/useEntityRootExec/types.js +5 -0
- package/lib/hooks/useEntityRootReturn/index.js +21 -0
- package/lib/hooks/useEntityRootReturn/types.js +5 -0
- package/lib/hooks/useExec/index.js +3 -12
- package/lib/hooks/useFullArguments/index.js +4 -6
- package/lib/hooks/useIfExec/index.js +27 -0
- package/lib/hooks/useIfExec/types.js +5 -0
- package/lib/hooks/useIfReturn/index.js +29 -0
- package/lib/hooks/useIfReturn/types.js +5 -0
- package/lib/hooks/useProvider/index.js +16 -22
- package/lib/hooks/useProviders/index.js +3 -3
- package/lib/hooks/useReducers/index.js +46 -29
- package/lib/hooks/useReturn/index.js +40 -0
- package/lib/hooks/useReturn/types.js +5 -0
- package/lib/hooks/useRootInitializing/index.js +20 -0
- package/lib/hooks/useRootReturn/index.js +30 -0
- package/lib/hooks/useRootReturn/types.js +5 -0
- package/lib/hooks/useStatuses/index.js +47 -21
- package/lib/hooks/useStore/index.js +19 -48
- package/lib/hooks/useThrottleUpdate/index.js +37 -0
- package/lib/hooks/useThrottleUpdate/types.js +5 -0
- package/lib/hooks/useUseCase/index.js +22 -25
- package/lib/hooks/useUseCase/index.test.js +360 -97
- package/lib/methods/cacheCall/index.js +44 -0
- package/lib/methods/cacheCall/types.js +5 -0
- package/lib/methods/cacheCalls/index.js +19 -0
- package/lib/usecases/contextUseCase/index.js +21 -38
- package/lib/usecases/lifecycleEventUseCase/index.js +48 -8
- package/package.json +3 -3
- package/es/enums/ArgumentTypes/index.d.ts +0 -4
- package/es/enums/ArgumentTypes/index.js +0 -5
- package/es/hooks/useArgumentTypes/index.d.ts +0 -3
- package/es/hooks/useArgumentTypes/index.js +0 -14
- package/es/hooks/useConstantEntityReducers/index.d.ts +0 -3
- package/es/hooks/useConstantEntityReducers/index.js +0 -7
- package/es/hooks/useConstantFn/index.d.ts +0 -1
- package/es/hooks/useConstantFn/index.js +0 -10
- package/es/hooks/useConstantReducers/index.d.ts +0 -3
- package/es/hooks/useConstantReducers/index.js +0 -6
- package/es/hooks/useContextualItem/index.d.ts +0 -4
- package/es/hooks/useContextualItem/index.js +0 -31
- package/es/hooks/useContextualItem/types.d.ts +0 -3
- package/es/hooks/useEntityInitializing/index.d.ts +0 -2
- package/es/hooks/useEntityInitializing/index.js +0 -16
- package/es/usecases/methodUseCase/index.d.ts +0 -2
- package/es/usecases/methodUseCase/index.js +0 -72
- package/es/usecases/methodUseCase/types.d.ts +0 -21
- package/lib/enums/ArgumentTypes/index.js +0 -11
- package/lib/hooks/useArgumentTypes/index.js +0 -22
- package/lib/hooks/useConstantEntityReducers/index.js +0 -13
- package/lib/hooks/useConstantFn/index.js +0 -17
- package/lib/hooks/useConstantReducers/index.js +0 -12
- package/lib/hooks/useContextualItem/index.js +0 -37
- package/lib/hooks/useEntityInitializing/index.js +0 -22
- package/lib/usecases/methodUseCase/index.js +0 -79
- /package/es/hooks/{useContextualItem → useChanged}/types.js +0 -0
- /package/es/{usecases/methodUseCase → hooks/useEntityReturn}/types.js +0 -0
- /package/lib/hooks/{useContextualItem → useChanged}/types.js +0 -0
- /package/lib/{usecases/methodUseCase → hooks/useEntityReturn}/types.js +0 -0
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useEntityInitializing = void 0;
|
|
7
|
-
var _useExec = require("../useExec");
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _Statuses = require("../../enums/Statuses");
|
|
10
|
-
var useEntityInitializing = exports.useEntityInitializing = function useEntityInitializing(statuses) {
|
|
11
|
-
var isInitializingRef = (0, _react.useRef)(true);
|
|
12
|
-
var entityRootEnabled = (statuses & _Statuses.Statuses.EntityRootEnabled) === _Statuses.Statuses.EntityRootEnabled;
|
|
13
|
-
return (0, _useExec.useExec)(function () {
|
|
14
|
-
if (!entityRootEnabled) {
|
|
15
|
-
isInitializingRef.current = true;
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
var isInitializing = isInitializingRef.current;
|
|
19
|
-
isInitializingRef.current = false;
|
|
20
|
-
return isInitializing;
|
|
21
|
-
});
|
|
22
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.methodUseCase = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
var _objectUtilsUseCase2 = require("../objectUtilsUseCase");
|
|
10
|
-
var methodUseCase = exports.methodUseCase = function methodUseCase() {
|
|
11
|
-
var _objectUtilsUseCase = (0, _objectUtilsUseCase2.objectUtilsUseCase)(),
|
|
12
|
-
isEqual = _objectUtilsUseCase.isEqual;
|
|
13
|
-
var cacheCall = function cacheCall(factory, options) {
|
|
14
|
-
var cache;
|
|
15
|
-
var _ref = options || {},
|
|
16
|
-
_ref$onShouldCache = _ref.onShouldCache,
|
|
17
|
-
onShouldCache = _ref$onShouldCache === void 0 ? function () {
|
|
18
|
-
return true;
|
|
19
|
-
} : _ref$onShouldCache,
|
|
20
|
-
_ref$onCompare = _ref.onCompare,
|
|
21
|
-
onCompare = _ref$onCompare === void 0 ? function (newArgs, oldArgs) {
|
|
22
|
-
return isEqual(newArgs, oldArgs);
|
|
23
|
-
} : _ref$onCompare;
|
|
24
|
-
return function () {
|
|
25
|
-
var cacheable = onShouldCache();
|
|
26
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
27
|
-
args[_key] = arguments[_key];
|
|
28
|
-
}
|
|
29
|
-
if (cache && cacheable) {
|
|
30
|
-
var _cache = cache,
|
|
31
|
-
parameters = _cache.parameters,
|
|
32
|
-
_returnValue = _cache.returnValue;
|
|
33
|
-
if (onCompare(parameters, args)) {
|
|
34
|
-
return _returnValue;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
var returnValue = factory.apply(void 0, args);
|
|
38
|
-
if (cacheable) {
|
|
39
|
-
cache = {
|
|
40
|
-
parameters: args,
|
|
41
|
-
returnValue: returnValue
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return returnValue;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
var cacheCalls = function cacheCalls(sourceFactories, options) {
|
|
48
|
-
var cachedFactories = {};
|
|
49
|
-
Object.entries(sourceFactories).forEach(function (_ref2) {
|
|
50
|
-
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 2),
|
|
51
|
-
key = _ref3[0],
|
|
52
|
-
factory = _ref3[1];
|
|
53
|
-
cachedFactories[key] = cacheCall(factory, options);
|
|
54
|
-
});
|
|
55
|
-
return cachedFactories;
|
|
56
|
-
};
|
|
57
|
-
var captureCalls = function captureCalls(obj, callback) {
|
|
58
|
-
var newObj = {};
|
|
59
|
-
Object.keys(obj).forEach(function (key) {
|
|
60
|
-
var value = obj[key];
|
|
61
|
-
if (typeof value === 'function') {
|
|
62
|
-
newObj[key] = function () {
|
|
63
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
64
|
-
args[_key2] = arguments[_key2];
|
|
65
|
-
}
|
|
66
|
-
return callback(key, args);
|
|
67
|
-
};
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
newObj[key] = value;
|
|
71
|
-
});
|
|
72
|
-
return newObj;
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
cacheCall: cacheCall,
|
|
76
|
-
cacheCalls: cacheCalls,
|
|
77
|
-
captureCalls: captureCalls
|
|
78
|
-
};
|
|
79
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|