@fluid-topics/ft-wc-utils 1.2.15 → 1.2.17
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.
|
@@ -13,7 +13,7 @@ export declare class FtLitElementRedux extends FtLitElement {
|
|
|
13
13
|
static reduxEventListeners: Map<string, ReduxEventListenerInit>;
|
|
14
14
|
private readonly [internalStoresUnsubscribers];
|
|
15
15
|
private readonly [internalStores];
|
|
16
|
-
private [internalReduxEventsUnsubscribers];
|
|
16
|
+
private readonly [internalReduxEventsUnsubscribers];
|
|
17
17
|
private get reduxConstructor();
|
|
18
18
|
protected update(props: PropertyValues): void;
|
|
19
19
|
private getUnnamedStore;
|
|
@@ -21,9 +21,11 @@ export declare class FtLitElementRedux extends FtLitElement {
|
|
|
21
21
|
protected addStore(store: FtReduxStore, name?: string): void;
|
|
22
22
|
protected addStore(store: Store, name: string): void;
|
|
23
23
|
protected removeStore(storeOrName: FtReduxStore | string): void;
|
|
24
|
-
private setupStore;
|
|
25
24
|
private setupStores;
|
|
26
25
|
private updateFromStores;
|
|
26
|
+
/**
|
|
27
|
+
* Only call after unsubscribeFromStores or unsubscribeFromStore with same name
|
|
28
|
+
*/
|
|
27
29
|
private subscribeToStore;
|
|
28
30
|
private unsubscribeFromStores;
|
|
29
31
|
private unsubscribeFromStore;
|
|
@@ -9,7 +9,7 @@ class FtLitElementRedux extends FtLitElement {
|
|
|
9
9
|
super(...arguments);
|
|
10
10
|
this[_a] = new Map();
|
|
11
11
|
this[_b] = new Map();
|
|
12
|
-
this[_c] =
|
|
12
|
+
this[_c] = new Map();
|
|
13
13
|
}
|
|
14
14
|
get reduxConstructor() {
|
|
15
15
|
return this.constructor;
|
|
@@ -35,18 +35,15 @@ class FtLitElementRedux extends FtLitElement {
|
|
|
35
35
|
var _d;
|
|
36
36
|
name = (_d = name !== null && name !== void 0 ? name : (isFtReduxStore(store) ? store.name : undefined)) !== null && _d !== void 0 ? _d : "default-store";
|
|
37
37
|
this.unsubscribeFromStore(name);
|
|
38
|
-
this.
|
|
38
|
+
this[internalStores].set(name, store);
|
|
39
|
+
this.subscribeToStore(name, store);
|
|
40
|
+
this.updateFromStores();
|
|
39
41
|
}
|
|
40
42
|
removeStore(storeOrName) {
|
|
41
43
|
const name = typeof storeOrName === "string" ? storeOrName : storeOrName.name;
|
|
42
44
|
this.unsubscribeFromStore(name);
|
|
43
45
|
this[internalStores].delete(name);
|
|
44
46
|
}
|
|
45
|
-
setupStore(name, store) {
|
|
46
|
-
this[internalStores].set(name, store);
|
|
47
|
-
this.subscribeToStore(name, store);
|
|
48
|
-
this.updateFromStores();
|
|
49
|
-
}
|
|
50
47
|
setupStores() {
|
|
51
48
|
this.unsubscribeFromStores();
|
|
52
49
|
this[internalStores].forEach((store, name) => this.subscribeToStore(name, store));
|
|
@@ -63,15 +60,19 @@ class FtLitElementRedux extends FtLitElement {
|
|
|
63
60
|
}
|
|
64
61
|
});
|
|
65
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Only call after unsubscribeFromStores or unsubscribeFromStore with same name
|
|
65
|
+
*/
|
|
66
66
|
subscribeToStore(name, store) {
|
|
67
67
|
var _d;
|
|
68
68
|
this[internalStoresUnsubscribers].set(name, store.subscribe(() => this.updateFromStores()));
|
|
69
|
+
this[internalReduxEventsUnsubscribers].set(name, []);
|
|
69
70
|
if (isFtReduxStore(store) && store.eventBus) {
|
|
70
71
|
(_d = this.reduxConstructor.reduxEventListeners) === null || _d === void 0 ? void 0 : _d.forEach((init, methodName) => {
|
|
71
72
|
if (typeof this[methodName] === "function" && (!init.store || store.name === init.store)) {
|
|
72
73
|
const callback = (e) => this[methodName](e);
|
|
73
74
|
store.addEventListener(init.eventName, callback);
|
|
74
|
-
this[internalReduxEventsUnsubscribers].push(() => store.removeEventListener(init.eventName, callback));
|
|
75
|
+
this[internalReduxEventsUnsubscribers].get(name).push(() => store.removeEventListener(init.eventName, callback));
|
|
75
76
|
}
|
|
76
77
|
});
|
|
77
78
|
}
|
|
@@ -79,14 +80,15 @@ class FtLitElementRedux extends FtLitElement {
|
|
|
79
80
|
}
|
|
80
81
|
unsubscribeFromStores() {
|
|
81
82
|
this[internalStoresUnsubscribers].forEach((_, key) => this.unsubscribeFromStore(key));
|
|
82
|
-
this[internalReduxEventsUnsubscribers].forEach(unsub => unsub());
|
|
83
|
-
this[internalReduxEventsUnsubscribers] = [];
|
|
84
83
|
}
|
|
85
84
|
unsubscribeFromStore(name) {
|
|
85
|
+
var _d;
|
|
86
86
|
if (this[internalStoresUnsubscribers].has(name)) {
|
|
87
87
|
this[internalStoresUnsubscribers].get(name)();
|
|
88
88
|
}
|
|
89
89
|
this[internalStoresUnsubscribers].delete(name);
|
|
90
|
+
(_d = this[internalReduxEventsUnsubscribers].get(name)) === null || _d === void 0 ? void 0 : _d.forEach(unsub => unsub());
|
|
91
|
+
this[internalReduxEventsUnsubscribers].delete(name);
|
|
90
92
|
}
|
|
91
93
|
onStoreAvailable(name) {
|
|
92
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-wc-utils",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.17",
|
|
4
4
|
"description": "Internal web components tools",
|
|
5
5
|
"author": "Fluid Topics <devtopics@antidot.net>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"mark.js": "8.11.1",
|
|
25
25
|
"moment": "2.29.4"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "fa3e6380c9989244a572de9d0067913ee624e09b"
|
|
28
28
|
}
|