@evlop/commons 1.0.226 → 1.0.227
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDataSource.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDataSource.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKxC,aAAK,cAAc,GAAG,QAAQ,GAAG,YAAY,GAAG,KAAK,GAAG,OAAO,GAAG,GAAG,CAAC;AACtE,UAAU,iBAAiB;IACvB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAE;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAC,MAAM,GAAG,GAAG,CAAC;CACrB;AAED,aAAK,IAAI,GAAG,UAAU,GAAG,MAAM,CAAC;AAIhC,eAAO,MAAM,aAAa,WAAa,MAAM,GAAG,iBAAiB,YAAa,iBAAiB,KAAI,IAgHlG,CAAC"}
|
1
|
+
{"version":3,"file":"useDataSource.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDataSource.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKxC,aAAK,cAAc,GAAG,QAAQ,GAAG,YAAY,GAAG,KAAK,GAAG,OAAO,GAAG,GAAG,CAAC;AACtE,UAAU,iBAAiB;IACvB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAE;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,CAAC,GAAG,EAAC,MAAM,GAAG,GAAG,CAAC;CACrB;AAED,aAAK,IAAI,GAAG,UAAU,GAAG,MAAM,CAAC;AAIhC,eAAO,MAAM,aAAa,WAAa,MAAM,GAAG,iBAAiB,YAAa,iBAAiB,KAAI,IAgHlG,CAAC"}
|
@@ -11,7 +11,7 @@ const classes_1 = require("../classes");
|
|
11
11
|
const reducers_1 = require("../reducers");
|
12
12
|
const useScope_1 = require("./useScope");
|
13
13
|
const useTemplate_1 = __importDefault(require("./useTemplate"));
|
14
|
-
const defaultDatasourceOptions = { memoize: true };
|
14
|
+
const defaultDatasourceOptions = { memoize: true, isReady: true };
|
15
15
|
const useDataSource = (source, options) => {
|
16
16
|
const dispatch = react_redux_1.useDispatch();
|
17
17
|
const template = useTemplate_1.default();
|
@@ -31,7 +31,7 @@ const useDataSource = (source, options) => {
|
|
31
31
|
const templatedValues = lodash_1.reduce(paramNames, (acc, paramName) => (Object.assign(Object.assign({}, acc), { [paramName]: template(lodash_1.get(_dataSourceOptions, paramName)) })), {});
|
32
32
|
return lodash_1.defaults(templatedValues, _dataSourceOptions);
|
33
33
|
}, [scope, template, dataSourceName, dataSource, _dataSourceOptions]);
|
34
|
-
const { memoize } = dataSourceOptions;
|
34
|
+
const { memoize, isReady } = dataSourceOptions;
|
35
35
|
const key = dataSource && dataSource.keyExtractor(dataSourceOptions, { scope, dispatch });
|
36
36
|
const currentValue = react_redux_1.useSelector(state => state.dataSource.data[key]);
|
37
37
|
const loadData = react_1.useCallback((params) => {
|
@@ -74,12 +74,12 @@ const useDataSource = (source, options) => {
|
|
74
74
|
});
|
75
75
|
}, [loadData, dataSourceOptions, scope, key]);
|
76
76
|
react_1.useEffect(() => {
|
77
|
-
if (dataSourceName === 'scope' || dataSourceName === 'static')
|
77
|
+
if (dataSourceName === 'scope' || dataSourceName === 'static' || !isReady)
|
78
78
|
return;
|
79
79
|
if (!currentValue || !memoize) {
|
80
80
|
loadData();
|
81
81
|
}
|
82
|
-
}, [dataSourceName, key, memoize]);
|
82
|
+
}, [dataSourceName, key, memoize, isReady]);
|
83
83
|
const value = react_1.useMemo(() => {
|
84
84
|
if (dataSourceName === 'scope' || dataSourceName === 'static')
|
85
85
|
return;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDataSource.js","sourceRoot":"","sources":["../../../src/hooks/useDataSource.tsx"],"names":[],"mappings":";;;;;;AAAA,mCAAiG;AACjG,iCAAwD;AACxD,6CAAuD;AACvD,wCAAwC;AACxC,0CAAmK;AACnK,yCAAsC;AACtC,gEAAwC;
|
1
|
+
{"version":3,"file":"useDataSource.js","sourceRoot":"","sources":["../../../src/hooks/useDataSource.tsx"],"names":[],"mappings":";;;;;;AAAA,mCAAiG;AACjG,iCAAwD;AACxD,6CAAuD;AACvD,wCAAwC;AACxC,0CAAmK;AACnK,yCAAsC;AACtC,gEAAwC;AAexC,MAAM,wBAAwB,GAAgC,EAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC,CAAA;AAErF,MAAM,aAAa,GAAG,CAAE,MAAkC,EAAG,OAA2B,EAAQ,EAAE;IACrG,MAAM,QAAQ,GAAG,yBAAW,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,qBAAW,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,mBAAQ,EAAE,CAAC;IAEzB,MAAM,EAAC,cAAc,EAAE,OAAO,EAAE,kBAAkB,EAAC,GAAG,eAAO,CAAC,GAAE,EAAE;QAC9D,IAAG,OAAO,MAAM,KAAK,QAAQ,EAAC;YAC1B,OAAO,EAAC,cAAc,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAQ,CAAC,aAAI,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,wBAAwB,CAAC,EAAE,CAAC;SAC9G;aAAK;YACF,OAAO,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC,EAAC,CAAC;SACzF;IACL,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEtB,MAA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