@applicaster/zapp-react-native-bridge 12.0.0-rc.26 → 12.0.0-rc.29
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.
|
@@ -33,11 +33,16 @@ export interface MultiSelectProvider {
|
|
|
33
33
|
|
|
34
34
|
export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
35
35
|
// TODO: Unsubscribe and remove when there is no listeners
|
|
36
|
-
private static multiSelectProviders: Record<
|
|
36
|
+
private static multiSelectProviders: Record<
|
|
37
|
+
string,
|
|
38
|
+
StorageMultiSelectProvider
|
|
39
|
+
> = {};
|
|
37
40
|
|
|
38
|
-
public static getProvider(keyNamespace:string): StorageMultiSelectProvider {
|
|
41
|
+
public static getProvider(keyNamespace: string): StorageMultiSelectProvider {
|
|
39
42
|
if (!this.multiSelectProviders[keyNamespace]) {
|
|
40
|
-
this.multiSelectProviders[keyNamespace] = new StorageMultiSelectProvider(
|
|
43
|
+
this.multiSelectProviders[keyNamespace] = new StorageMultiSelectProvider(
|
|
44
|
+
keyNamespace
|
|
45
|
+
);
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
return this.multiSelectProviders[keyNamespace];
|
|
@@ -45,8 +50,8 @@ export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
|
45
50
|
|
|
46
51
|
private itemSubject: BehaviorSubject<string[] | null>;
|
|
47
52
|
|
|
48
|
-
private readonly key:string
|
|
49
|
-
private readonly namespace:string;
|
|
53
|
+
private readonly key: string;
|
|
54
|
+
private readonly namespace: string;
|
|
50
55
|
|
|
51
56
|
private constructor(keyNamespace: string) {
|
|
52
57
|
const { namespace, key } = getNamespaceAndKey(keyNamespace);
|
|
@@ -65,10 +70,13 @@ export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
|
65
70
|
log_debug("StorageMultiSelectProvider: Initializing");
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
private reloadItems = async ({ value }:StorageListenerArgs) => {
|
|
73
|
+
private reloadItems = async ({ value }: StorageListenerArgs) => {
|
|
69
74
|
const selectedItems = value ? value.split(",") : [];
|
|
70
75
|
|
|
71
|
-
log_debug(
|
|
76
|
+
log_debug(
|
|
77
|
+
`reloadItems: request to reload items for value: ${value}`,
|
|
78
|
+
selectedItems
|
|
79
|
+
);
|
|
72
80
|
|
|
73
81
|
this.itemSubject.next(selectedItems);
|
|
74
82
|
};
|
|
@@ -76,7 +84,10 @@ export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
|
76
84
|
public getObservable = (): BehaviorSubject<string[]> => this.itemSubject;
|
|
77
85
|
|
|
78
86
|
private async getSetOfCurrentItems() {
|
|
79
|
-
const currentResult: string = await localStorage.getItem(
|
|
87
|
+
const currentResult: string = await localStorage.getItem(
|
|
88
|
+
this.key,
|
|
89
|
+
this.namespace
|
|
90
|
+
);
|
|
80
91
|
|
|
81
92
|
return new Set(currentResult ? currentResult.split(",") : []);
|
|
82
93
|
}
|
|
@@ -89,49 +100,61 @@ export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
|
89
100
|
this.itemSubject.next(arrayOfItems);
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
public addItem = async(item: string): Promise<void> => {
|
|
103
|
+
public addItem = async (item: string): Promise<void> => {
|
|
93
104
|
const currentItems = await this.getSetOfCurrentItems();
|
|
94
105
|
currentItems.add(item);
|
|
95
106
|
log_debug(`addItem: Adding new item: ${item}`);
|
|
96
107
|
|
|
97
108
|
await this.updateItemsAndNotifyObservers(currentItems);
|
|
98
|
-
}
|
|
109
|
+
};
|
|
99
110
|
|
|
100
|
-
public addItems = async(items: string[]): Promise<void> => {
|
|
111
|
+
public addItems = async (items: string[]): Promise<void> => {
|
|
101
112
|
const currentItems = await this.getSetOfCurrentItems();
|
|
102
113
|
|
|
103
114
|
items.forEach((item) => currentItems.add(item));
|
|
104
115
|
|
|
105
|
-
log_debug(
|
|
116
|
+
log_debug(
|
|
117
|
+
`addItems: Adding new items: ${items.join(
|
|
118
|
+
","
|
|
119
|
+
)}, current items: ${Array.from(currentItems).join(",")}`
|
|
120
|
+
);
|
|
106
121
|
|
|
107
122
|
await this.updateItemsAndNotifyObservers(currentItems);
|
|
108
|
-
}
|
|
123
|
+
};
|
|
109
124
|
|
|
110
|
-
public removeItem = async(item: string): Promise<void> => {
|
|
125
|
+
public removeItem = async (item: string): Promise<void> => {
|
|
111
126
|
const currentItems = await this.getSetOfCurrentItems();
|
|
112
127
|
currentItems.delete(item);
|
|
113
128
|
|
|
114
|
-
log_debug(
|
|
129
|
+
log_debug(
|
|
130
|
+
`removeItem: Removing item: ${item}, current items: ${Array.from(
|
|
131
|
+
currentItems
|
|
132
|
+
).join(",")}`
|
|
133
|
+
);
|
|
115
134
|
|
|
116
135
|
await this.updateItemsAndNotifyObservers(currentItems);
|
|
117
|
-
}
|
|
136
|
+
};
|
|
118
137
|
|
|
119
138
|
public removeItems = async (items: string[]): Promise<void> => {
|
|
120
139
|
const currentItems = await this.getSetOfCurrentItems();
|
|
121
140
|
|
|
122
141
|
items.forEach((item) => currentItems.delete(item));
|
|
123
142
|
|
|
124
|
-
log_debug(
|
|
143
|
+
log_debug(
|
|
144
|
+
`removeItems: Removing items: ${items.join(
|
|
145
|
+
","
|
|
146
|
+
)}, current items: ${Array.from(currentItems).join(",")}`
|
|
147
|
+
);
|
|
125
148
|
|
|
126
149
|
await this.updateItemsAndNotifyObservers(currentItems);
|
|
127
|
-
}
|
|
150
|
+
};
|
|
128
151
|
|
|
129
152
|
public removeAllItems = async (): Promise<void> => {
|
|
130
153
|
await localStorage.removeItem(this.key, this.namespace);
|
|
131
154
|
log_debug(`removeAllItems: Removing all items, current items: ${[]}`);
|
|
132
155
|
|
|
133
156
|
this.itemSubject.next([]);
|
|
134
|
-
}
|
|
157
|
+
};
|
|
135
158
|
|
|
136
159
|
public getSelectedAsync = async (): Promise<string[]> => {
|
|
137
160
|
const value = await localStorage.getItem(this.key, this.namespace);
|
|
@@ -139,15 +162,15 @@ export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
|
139
162
|
this.itemSubject.next(selectedItems);
|
|
140
163
|
|
|
141
164
|
return selectedItems;
|
|
142
|
-
}
|
|
165
|
+
};
|
|
143
166
|
|
|
144
167
|
public getSelectedItems = (): string[] => {
|
|
145
168
|
return this.itemSubject.getValue();
|
|
146
|
-
}
|
|
169
|
+
};
|
|
147
170
|
|
|
148
171
|
setSelectedItems = async (items: string[]): Promise<void> => {
|
|
149
172
|
log_debug(`setSelectedItems: Setting selected items: ${items.join(",")}`);
|
|
150
173
|
|
|
151
174
|
await this.updateItemsAndNotifyObservers(new Set(items));
|
|
152
|
-
}
|
|
175
|
+
};
|
|
153
176
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-bridge",
|
|
3
|
-
"version": "12.0.0-rc.
|
|
3
|
+
"version": "12.0.0-rc.29",
|
|
4
4
|
"description": "Applicaster Zapp React Native modules",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@applicaster/zapp-pipes-dev-kit": "1.4.7",
|
|
36
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-rc.
|
|
36
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-rc.29",
|
|
37
37
|
"md5": "^2.3.0",
|
|
38
38
|
"uuid": "^3.3.2"
|
|
39
39
|
},
|