@tramvai/state 4.41.98 → 4.41.100

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.
@@ -29,6 +29,7 @@ export declare class ChildDispatcherContext<TContext> extends DispatcherContext<
29
29
  }): InstanceType<T> | null;
30
30
  registerStore(store: Reducer<any>): void;
31
31
  unregisterStore(store: Reducer<any>): void;
32
+ hasStore(store: Reducer<any> | string): boolean;
32
33
  _getParentAllowedStore(storeName: string): InstanceType<StoreClass> | null;
33
34
  _unsubscribeFromParentAllowedStore(storeName: string): void;
34
35
  }
@@ -57,6 +57,20 @@ class ChildDispatcherContext extends DispatcherContext {
57
57
  }
58
58
  super.unregisterStore(store);
59
59
  }
60
+ hasStore(store) {
61
+ const storeName = typeof store === 'string' ? store : store.storeName;
62
+ const storeObj = typeof store === 'string' ? { storeName } : store;
63
+ if (this.dispatcher.stores[storeName]) {
64
+ return super.hasStore(storeObj);
65
+ }
66
+ if (this.allowedParentStores.has(storeName)) {
67
+ return !!this.parentDispatcherContext.getStore({
68
+ store: storeName,
69
+ optional: true,
70
+ });
71
+ }
72
+ return super.hasStore(storeObj);
73
+ }
60
74
  _getParentAllowedStore(storeName) {
61
75
  // use just storeName to prevent store initialization on the root-app side
62
76
  const storeInstance = this.parentDispatcherContext.getStore({
@@ -61,6 +61,20 @@ class ChildDispatcherContext extends dispatcherContext.DispatcherContext {
61
61
  }
62
62
  super.unregisterStore(store);
63
63
  }
64
+ hasStore(store) {
65
+ const storeName = typeof store === 'string' ? store : store.storeName;
66
+ const storeObj = typeof store === 'string' ? { storeName } : store;
67
+ if (this.dispatcher.stores[storeName]) {
68
+ return super.hasStore(storeObj);
69
+ }
70
+ if (this.allowedParentStores.has(storeName)) {
71
+ return !!this.parentDispatcherContext.getStore({
72
+ store: storeName,
73
+ optional: true,
74
+ });
75
+ }
76
+ return super.hasStore(storeObj);
77
+ }
64
78
  _getParentAllowedStore(storeName) {
65
79
  // use just storeName to prevent store initialization on the root-app side
66
80
  const storeInstance = this.parentDispatcherContext.getStore({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/state",
3
- "version": "4.41.98",
3
+ "version": "4.41.100",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@tinkoff/react-hooks": "0.3.3",
21
21
  "@tinkoff/utils": "^2.1.2",
22
- "@tramvai/types-actions-state-context": "4.41.98",
22
+ "@tramvai/types-actions-state-context": "4.41.100",
23
23
  "@types/hoist-non-react-statics": "^3.3.1",
24
24
  "invariant": "^2.2.4",
25
25
  "react-is": ">=17",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "@reatom/core": "^1.1.5",
37
- "@tramvai/core": "4.41.98",
37
+ "@tramvai/core": "4.41.100",
38
38
  "@types/invariant": "^2.2.31",
39
39
  "@types/react-is": "^17.0.0",
40
40
  "@types/use-sync-external-store": "^0.0.3",