yummies 3.1.5 → 3.1.7
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.
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { AnyObject } from '../utils/types.js';
|
|
1
|
+
import { AnyObject, Maybe } from '../utils/types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Создает глобальный конфиг, который может быть доступен в любой точке в коде
|
|
4
4
|
*/
|
|
5
5
|
export declare const createGlobalConfig: <T extends AnyObject>(defaultValue: T, accessSymbol?: any) => T;
|
|
6
|
-
export declare const createGlobalDynamicConfig: <T extends AnyObject>(
|
|
7
|
-
update: (value: Partial<T>) => void;
|
|
6
|
+
export declare const createGlobalDynamicConfig: <T extends AnyObject>(processFn: (change: Maybe<Partial<T>>, current: Maybe<T>) => T, accessSymbol?: any) => {
|
|
8
7
|
get: () => T;
|
|
9
|
-
set: (value:
|
|
8
|
+
set: (value: T | null | undefined) => T | null | undefined;
|
|
9
|
+
update: (value: Partial<T>) => void;
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=global-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../../src/complex/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../../src/complex/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAWrD;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,SAAS,gBACtC,CAAC,iBACD,GAAG,MAIlB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,CAAC,SAAS,SAAS,aAChD,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,iBAChD,GAAG;;;oBAeC,OAAO,CAAC,CAAC,CAAC;CAK7B,CAAC"}
|
package/complex/global-config.js
CHANGED
|
@@ -12,12 +12,21 @@ export const createGlobalConfig = (defaultValue, accessSymbol = Symbol()) => {
|
|
|
12
12
|
const globalPoint = createGlobalPoint(accessSymbol);
|
|
13
13
|
return globalPoint.get() || globalPoint.set(defaultValue);
|
|
14
14
|
};
|
|
15
|
-
export const createGlobalDynamicConfig = (
|
|
15
|
+
export const createGlobalDynamicConfig = (processFn, accessSymbol = Symbol()) => {
|
|
16
16
|
const globalPoint = createGlobalPoint(accessSymbol);
|
|
17
|
+
const getValue = () => {
|
|
18
|
+
const currentValue = globalPoint.get();
|
|
19
|
+
if (currentValue == null) {
|
|
20
|
+
return globalPoint.set(processFn(null, null));
|
|
21
|
+
}
|
|
22
|
+
return currentValue;
|
|
23
|
+
};
|
|
17
24
|
return {
|
|
18
|
-
|
|
25
|
+
get: getValue,
|
|
26
|
+
set: globalPoint.set,
|
|
19
27
|
update: (value) => {
|
|
20
|
-
|
|
28
|
+
const currentValue = getValue();
|
|
29
|
+
Object.assign(currentValue, processFn(value, currentValue));
|
|
21
30
|
},
|
|
22
31
|
};
|
|
23
32
|
};
|