@smartsoft001/angular 2.179.0 → 2.181.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.
|
@@ -1982,15 +1982,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
1982
1982
|
}]
|
|
1983
1983
|
}] });
|
|
1984
1984
|
|
|
1985
|
+
const registeredKeys = new WeakMap();
|
|
1985
1986
|
class NgrxStoreService {
|
|
1986
|
-
static _reducers = {};
|
|
1987
1987
|
static store = undefined;
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1988
|
+
/**
|
|
1989
|
+
* Registers a feature reducer once per Store instance.
|
|
1990
|
+
*
|
|
1991
|
+
* @param store target Store; defaults to the connected `NgrxStoreService.store`.
|
|
1992
|
+
* Pass it explicitly under SSR, where one process renders many app instances,
|
|
1993
|
+
* each with its own Store.
|
|
1994
|
+
*/
|
|
1995
|
+
static addReducer(key, reducer, store) {
|
|
1996
|
+
const target = store ?? NgrxStoreService.store;
|
|
1997
|
+
if (!target)
|
|
1998
|
+
return;
|
|
1999
|
+
const keys = registeredKeys.get(target) ?? new Set();
|
|
2000
|
+
registeredKeys.set(target, keys);
|
|
2001
|
+
const alreadyInStore = !!target.reducerManager?.currentReducers?.[key];
|
|
2002
|
+
if (keys.has(key) || alreadyInStore)
|
|
2003
|
+
return;
|
|
2004
|
+
keys.add(key);
|
|
2005
|
+
target.addReducer(key, reducer);
|
|
1994
2006
|
}
|
|
1995
2007
|
connect(store) {
|
|
1996
2008
|
NgrxStoreService.store = store;
|