react-native-asleep 0.0.7 → 0.0.9
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.
- package/License.md +18 -0
- package/README.md +389 -18
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/build.gradle +1 -0
- package/android/src/main/java/ai/asleep/reactnative/AsleepModule.kt +98 -1
- package/build/Asleep.types.d.ts +27 -1
- package/build/Asleep.types.d.ts.map +1 -1
- package/build/Asleep.types.js.map +1 -1
- package/build/AsleepStore.d.ts +50 -0
- package/build/AsleepStore.d.ts.map +1 -0
- package/build/AsleepStore.js +314 -0
- package/build/AsleepStore.js.map +1 -0
- package/build/index.d.ts +38 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +42 -167
- package/build/index.js.map +1 -1
- package/ios/AsleepModule.swift +67 -2
- package/package.json +5 -3
- package/src/Asleep.types.ts +23 -1
- package/src/AsleepStore.ts +436 -0
- package/src/index.ts +91 -219
- package/android/.gradle/8.5/checksums/checksums.lock +0 -0
- package/android/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/config.properties +0 -2
- package/android/.idea/android.iml +0 -9
- package/android/.idea/appInsightsSettings.xml +0 -23
- package/android/.idea/caches/deviceStreaming.xml +0 -329
- package/android/.idea/gradle.xml +0 -13
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/modules.xml +0 -8
- package/android/.idea/vcs.xml +0 -7
- package/android/local.properties +0 -8
- /package/android/.gradle/{8.5 → 8.9}/dependencies-accessors/gc.properties +0 -0
- /package/android/.gradle/{8.5 → 8.9}/fileChanges/last-build.bin +0 -0
- /package/android/.gradle/{8.5 → 8.9}/gc.properties +0 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
import { subscribeWithSelector } from "zustand/middleware";
|
|
3
|
+
import { EventEmitter } from "expo-modules-core";
|
|
4
|
+
import { Alert, Platform } from "react-native";
|
|
5
|
+
import {
|
|
6
|
+
AsleepConfig,
|
|
7
|
+
AsleepSetupConfig,
|
|
8
|
+
AsleepEventType,
|
|
9
|
+
AsleepReport,
|
|
10
|
+
AsleepSession,
|
|
11
|
+
AsleepAnalysisResult,
|
|
12
|
+
} from "./Asleep.types";
|
|
13
|
+
import AsleepModule from "./AsleepModule";
|
|
14
|
+
|
|
15
|
+
const emitter = new EventEmitter(AsleepModule);
|
|
16
|
+
|
|
17
|
+
export interface AsleepState {
|
|
18
|
+
didClose: boolean;
|
|
19
|
+
isTracking: boolean;
|
|
20
|
+
isTrackingPaused: boolean;
|
|
21
|
+
error: string | null;
|
|
22
|
+
userId: string | null;
|
|
23
|
+
sessionId: string | null;
|
|
24
|
+
showDebugLog: boolean;
|
|
25
|
+
log: string;
|
|
26
|
+
analysisResult: AsleepAnalysisResult | null;
|
|
27
|
+
isODAEnabled: boolean;
|
|
28
|
+
isAnalyzing: boolean;
|
|
29
|
+
trackingStartTime: Date | null;
|
|
30
|
+
isInitialized: boolean;
|
|
31
|
+
|
|
32
|
+
// actions
|
|
33
|
+
setup: (config: AsleepSetupConfig) => Promise<void>;
|
|
34
|
+
initAsleepConfig: (config: AsleepConfig) => Promise<void>;
|
|
35
|
+
startTracking: () => Promise<void>;
|
|
36
|
+
stopTracking: () => Promise<void>;
|
|
37
|
+
getReport: (sessionId: string) => Promise<AsleepReport | null>;
|
|
38
|
+
getReportList: (fromDate: string, toDate: string) => Promise<AsleepSession[]>;
|
|
39
|
+
requestMicrophonePermission: () => Promise<boolean>;
|
|
40
|
+
setCustomNotification: (title: string, text: string) => Promise<void>;
|
|
41
|
+
enableLog: (print: boolean) => void;
|
|
42
|
+
requestAnalysis: () => Promise<AsleepAnalysisResult | null>;
|
|
43
|
+
addEventListener: <K extends keyof AsleepEventType>(
|
|
44
|
+
eventType: K,
|
|
45
|
+
listener: (data: AsleepEventType[K]) => void
|
|
46
|
+
) => () => void;
|
|
47
|
+
getTrackingDurationMinutes: () => number;
|
|
48
|
+
|
|
49
|
+
// internal actions
|
|
50
|
+
setError: (error: string | null) => void;
|
|
51
|
+
setUserId: (userId: string | null) => void;
|
|
52
|
+
setSessionId: (sessionId: string | null) => void;
|
|
53
|
+
setIsTracking: (isTracking: boolean) => void;
|
|
54
|
+
setIsTrackingPaused: (isTrackingPaused: boolean) => void;
|
|
55
|
+
setDidClose: (didClose: boolean) => void;
|
|
56
|
+
setanalysisResult: (result: AsleepAnalysisResult | null) => void;
|
|
57
|
+
setIsAnalyzing: (isAnalyzing: boolean) => void;
|
|
58
|
+
setTrackingStartTime: (time: Date | null) => void;
|
|
59
|
+
setIsInitialized: (initialized: boolean) => void;
|
|
60
|
+
addLog: (log: string) => void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const convertKeysToCamelCase = (obj: any): any => {
|
|
64
|
+
if (Array.isArray(obj)) {
|
|
65
|
+
return obj.map(convertKeysToCamelCase);
|
|
66
|
+
} else if (obj !== null && obj.constructor === Object) {
|
|
67
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
68
|
+
const camelKey = key.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
|
|
69
|
+
acc[camelKey] = convertKeysToCamelCase(obj[key]);
|
|
70
|
+
return acc;
|
|
71
|
+
}, {} as any);
|
|
72
|
+
}
|
|
73
|
+
return obj;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const useAsleepStore = create<AsleepState>()(
|
|
77
|
+
subscribeWithSelector((set, get) => ({
|
|
78
|
+
// initial state
|
|
79
|
+
didClose: false,
|
|
80
|
+
isTracking: AsleepModule.isTracking ? AsleepModule.isTracking() : false,
|
|
81
|
+
isTrackingPaused: false,
|
|
82
|
+
error: null,
|
|
83
|
+
userId: null,
|
|
84
|
+
sessionId: null,
|
|
85
|
+
showDebugLog: false,
|
|
86
|
+
log: "",
|
|
87
|
+
analysisResult: null,
|
|
88
|
+
isODAEnabled: false,
|
|
89
|
+
isAnalyzing: false,
|
|
90
|
+
trackingStartTime: null,
|
|
91
|
+
isInitialized: false,
|
|
92
|
+
|
|
93
|
+
// actions
|
|
94
|
+
setup: async (config: AsleepSetupConfig) => {
|
|
95
|
+
try {
|
|
96
|
+
const { addLog } = get();
|
|
97
|
+
addLog("[setup] Start");
|
|
98
|
+
|
|
99
|
+
await AsleepModule.setup(
|
|
100
|
+
config.apiKey,
|
|
101
|
+
config.baseUrl,
|
|
102
|
+
config.callbackUrl,
|
|
103
|
+
config.service,
|
|
104
|
+
config.enableODA
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// Store ODA enabled state
|
|
108
|
+
set({ isODAEnabled: config.enableODA || false, isInitialized: true });
|
|
109
|
+
addLog(`[setup] Success - ODA enabled: ${config.enableODA || false}`);
|
|
110
|
+
} catch (error: any) {
|
|
111
|
+
console.error("setup error:", error);
|
|
112
|
+
set({ error: error.message });
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
initAsleepConfig: async (config: AsleepConfig) => {
|
|
118
|
+
try {
|
|
119
|
+
const { addLog } = get();
|
|
120
|
+
addLog("[initAsleepConfig] Start");
|
|
121
|
+
|
|
122
|
+
const result = await AsleepModule.initAsleepConfig(
|
|
123
|
+
config.apiKey,
|
|
124
|
+
config.userId,
|
|
125
|
+
config.baseUrl,
|
|
126
|
+
config.callbackUrl
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
addLog("[initAsleepConfig] Success");
|
|
130
|
+
return result;
|
|
131
|
+
} catch (error: any) {
|
|
132
|
+
console.error("initAsleepConfig error:", error);
|
|
133
|
+
set({ error: error.message });
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
startTracking: async () => {
|
|
139
|
+
try {
|
|
140
|
+
const { requestMicrophonePermission, addLog, isODAEnabled } = get();
|
|
141
|
+
addLog("[startTracking] Start");
|
|
142
|
+
|
|
143
|
+
const permission = await requestMicrophonePermission();
|
|
144
|
+
if (!permission) {
|
|
145
|
+
Alert.alert("Microphone permission denied");
|
|
146
|
+
throw new Error("Microphone permission denied");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
set({
|
|
150
|
+
didClose: false,
|
|
151
|
+
isTracking: true,
|
|
152
|
+
isAnalyzing: false,
|
|
153
|
+
trackingStartTime: new Date(),
|
|
154
|
+
});
|
|
155
|
+
await AsleepModule.startTracking();
|
|
156
|
+
|
|
157
|
+
if (isODAEnabled) {
|
|
158
|
+
addLog(
|
|
159
|
+
"[startTracking] ODA enabled - real-time analysis will start automatically"
|
|
160
|
+
);
|
|
161
|
+
} else {
|
|
162
|
+
addLog("[startTracking] ODA not enabled");
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
addLog("[startTracking] Success");
|
|
166
|
+
} catch (error: any) {
|
|
167
|
+
console.error("startTracking error:", error);
|
|
168
|
+
set({
|
|
169
|
+
error: error.message,
|
|
170
|
+
isTracking: false,
|
|
171
|
+
isAnalyzing: false,
|
|
172
|
+
trackingStartTime: null,
|
|
173
|
+
});
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
stopTracking: async () => {
|
|
179
|
+
try {
|
|
180
|
+
const { addLog } = get();
|
|
181
|
+
addLog("[stopTracking] Start");
|
|
182
|
+
|
|
183
|
+
const sessionId = await AsleepModule.stopTracking();
|
|
184
|
+
set({
|
|
185
|
+
didClose: true,
|
|
186
|
+
sessionId,
|
|
187
|
+
isTracking: false,
|
|
188
|
+
isAnalyzing: false,
|
|
189
|
+
trackingStartTime: null,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
addLog(`[stopTracking] Success - sessionId: ${sessionId}`);
|
|
193
|
+
} catch (error: any) {
|
|
194
|
+
console.error("stopTracking error:", error);
|
|
195
|
+
set({ error: error.message });
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
getReport: async (sessionId: string) => {
|
|
201
|
+
try {
|
|
202
|
+
const { addLog } = get();
|
|
203
|
+
addLog(`[getReport] sessionId: ${sessionId}`);
|
|
204
|
+
|
|
205
|
+
const report = await AsleepModule.getReport(sessionId);
|
|
206
|
+
const convertedReport = convertKeysToCamelCase(report);
|
|
207
|
+
|
|
208
|
+
addLog("[getReport] Success");
|
|
209
|
+
return convertedReport;
|
|
210
|
+
} catch (error: any) {
|
|
211
|
+
console.error("getReport error:", error);
|
|
212
|
+
set({ error: error.message });
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
getReportList: async (fromDate: string, toDate: string) => {
|
|
218
|
+
try {
|
|
219
|
+
const { addLog } = get();
|
|
220
|
+
addLog(`[getReportList] fromDate: ${fromDate}, toDate: ${toDate}`);
|
|
221
|
+
|
|
222
|
+
const reportList = await AsleepModule.getReportList(fromDate, toDate);
|
|
223
|
+
const convertedList = reportList.map(convertKeysToCamelCase);
|
|
224
|
+
|
|
225
|
+
addLog("[getReportList] Success");
|
|
226
|
+
return convertedList;
|
|
227
|
+
} catch (error: any) {
|
|
228
|
+
console.error("getReportList error:", error);
|
|
229
|
+
set({ error: error.message });
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
requestMicrophonePermission: async () => {
|
|
235
|
+
return AsleepModule.requestMicrophonePermission();
|
|
236
|
+
},
|
|
237
|
+
|
|
238
|
+
setCustomNotification: async (title: string, text: string) => {
|
|
239
|
+
if (Platform.OS === "android") {
|
|
240
|
+
await AsleepModule.setCustomNotification(title, text);
|
|
241
|
+
} else {
|
|
242
|
+
console.warn("setCustomNotification is not supported on this platform");
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
enableLog: (print: boolean) => {
|
|
247
|
+
set({ showDebugLog: print });
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
requestAnalysis: async () => {
|
|
251
|
+
try {
|
|
252
|
+
const { addLog } = get();
|
|
253
|
+
addLog("[requestAnalysis] Start");
|
|
254
|
+
|
|
255
|
+
// When analysis starts, set isAnalyzing to true
|
|
256
|
+
set({ isAnalyzing: true });
|
|
257
|
+
|
|
258
|
+
const result = await AsleepModule.requestAnalysis();
|
|
259
|
+
const convertedResult = convertKeysToCamelCase(result);
|
|
260
|
+
|
|
261
|
+
if (Platform.OS === "android") {
|
|
262
|
+
set({ analysisResult: convertedResult });
|
|
263
|
+
}
|
|
264
|
+
addLog(
|
|
265
|
+
`[requestAnalysis] Success - ${JSON.stringify(convertedResult)}`
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
return convertedResult;
|
|
269
|
+
} catch (error: any) {
|
|
270
|
+
console.error("requestAnalysis error:", error);
|
|
271
|
+
set({ error: error.message, isAnalyzing: false });
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
addEventListener: <K extends keyof AsleepEventType>(
|
|
277
|
+
eventType: K,
|
|
278
|
+
listener: (data: AsleepEventType[K]) => void
|
|
279
|
+
) => {
|
|
280
|
+
const subscription = emitter.addListener(eventType, listener);
|
|
281
|
+
return () => subscription.remove();
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
getTrackingDurationMinutes: () => {
|
|
285
|
+
const { trackingStartTime } = get();
|
|
286
|
+
if (!trackingStartTime) return 0;
|
|
287
|
+
return Math.floor(
|
|
288
|
+
(Date.now() - trackingStartTime.getTime()) / (1000 * 60)
|
|
289
|
+
);
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
// internal actions
|
|
293
|
+
setError: (error) => set({ error }),
|
|
294
|
+
setUserId: (userId) => set({ userId }),
|
|
295
|
+
setSessionId: (sessionId) => set({ sessionId }),
|
|
296
|
+
setIsTracking: (isTracking) => set({ isTracking }),
|
|
297
|
+
setIsTrackingPaused: (isTrackingPaused) => set({ isTrackingPaused }),
|
|
298
|
+
setDidClose: (didClose) => set({ didClose }),
|
|
299
|
+
setanalysisResult: (result) => set({ analysisResult: result }),
|
|
300
|
+
setIsAnalyzing: (isAnalyzing) => set({ isAnalyzing }),
|
|
301
|
+
setTrackingStartTime: (time) => set({ trackingStartTime: time }),
|
|
302
|
+
setIsInitialized: (initialized) => set({ isInitialized: initialized }),
|
|
303
|
+
|
|
304
|
+
addLog: (log: string) => {
|
|
305
|
+
const { showDebugLog } = get();
|
|
306
|
+
const now = new Date();
|
|
307
|
+
const dateString = `${now.getHours().toString().padStart(2, "0")}:${now
|
|
308
|
+
.getMinutes()
|
|
309
|
+
.toString()
|
|
310
|
+
.padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}`;
|
|
311
|
+
|
|
312
|
+
const formattedLog = `[${dateString}]${log}`;
|
|
313
|
+
|
|
314
|
+
if (showDebugLog) {
|
|
315
|
+
console.log(`[Asleep]${formattedLog}`);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
set({ log: formattedLog });
|
|
319
|
+
},
|
|
320
|
+
}))
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
// initialize event listeners
|
|
324
|
+
export const initializeAsleepListeners = () => {
|
|
325
|
+
const store = useAsleepStore.getState();
|
|
326
|
+
const {
|
|
327
|
+
addLog,
|
|
328
|
+
setUserId,
|
|
329
|
+
setSessionId,
|
|
330
|
+
setIsTracking,
|
|
331
|
+
setIsTrackingPaused,
|
|
332
|
+
setError,
|
|
333
|
+
setDidClose,
|
|
334
|
+
setanalysisResult,
|
|
335
|
+
setIsAnalyzing,
|
|
336
|
+
} = store;
|
|
337
|
+
|
|
338
|
+
// event handlers
|
|
339
|
+
const handlers = {
|
|
340
|
+
onUserJoined: (data: any) => {
|
|
341
|
+
setUserId(data.userId);
|
|
342
|
+
addLog(`[onUserJoined] userId: ${data.userId}`);
|
|
343
|
+
},
|
|
344
|
+
onUserJoinFailed: (error: any) => {
|
|
345
|
+
const errorString = JSON.stringify(error);
|
|
346
|
+
setError(errorString);
|
|
347
|
+
addLog(`[onUserJoinFailed] error: ${errorString}`);
|
|
348
|
+
},
|
|
349
|
+
onUserDeleted: (data: any) => {
|
|
350
|
+
setUserId(null);
|
|
351
|
+
addLog(`[onUserDeleted] userId: ${data.userId}`);
|
|
352
|
+
},
|
|
353
|
+
onTrackingCreated: (data: any) => {
|
|
354
|
+
setIsTracking(true);
|
|
355
|
+
if (data && data.sessionId) {
|
|
356
|
+
setSessionId(data.sessionId);
|
|
357
|
+
}
|
|
358
|
+
addLog(
|
|
359
|
+
`[onTrackingCreated]${
|
|
360
|
+
data?.sessionId ? ` sessionId: ${data.sessionId}` : ""
|
|
361
|
+
}`
|
|
362
|
+
);
|
|
363
|
+
},
|
|
364
|
+
onTrackingUploaded: (data: any) => {
|
|
365
|
+
addLog(`[onTrackingUploaded] sequence: ${data.sequence}`);
|
|
366
|
+
|
|
367
|
+
// Request analysis automatically if ODA is enabled
|
|
368
|
+
const state = useAsleepStore.getState();
|
|
369
|
+
if (state.isODAEnabled && state.isTracking) {
|
|
370
|
+
state.setIsAnalyzing(true);
|
|
371
|
+
state.requestAnalysis().catch((error) => {
|
|
372
|
+
addLog(`[onTrackingUploaded] Auto analysis failed: ${error.message}`);
|
|
373
|
+
state.setIsAnalyzing(false);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
onTrackingClosed: (data: { sessionId: string }) => {
|
|
378
|
+
setSessionId(data.sessionId);
|
|
379
|
+
setDidClose(true);
|
|
380
|
+
setIsTracking(false);
|
|
381
|
+
setIsAnalyzing(false);
|
|
382
|
+
addLog(`[onTrackingClosed] sessionId: ${data.sessionId}`);
|
|
383
|
+
},
|
|
384
|
+
onTrackingFailed: (error: any) => {
|
|
385
|
+
const errorString = JSON.stringify(error);
|
|
386
|
+
setError(errorString);
|
|
387
|
+
setIsTracking(false);
|
|
388
|
+
setIsAnalyzing(false);
|
|
389
|
+
store.setTrackingStartTime(null);
|
|
390
|
+
addLog(`[onTrackingFailed] error: ${errorString}`);
|
|
391
|
+
},
|
|
392
|
+
onTrackingInterrupted: () => {
|
|
393
|
+
setIsTrackingPaused(true);
|
|
394
|
+
addLog(`[onTrackingInterrupted]`);
|
|
395
|
+
},
|
|
396
|
+
onTrackingResumed: () => {
|
|
397
|
+
setIsTrackingPaused(false);
|
|
398
|
+
addLog(`[onTrackingResumed]`);
|
|
399
|
+
},
|
|
400
|
+
onMicPermissionDenied: () => {
|
|
401
|
+
addLog(`[onMicPermissionDenied]`);
|
|
402
|
+
},
|
|
403
|
+
onDebugLog: (data: any) => {
|
|
404
|
+
addLog(`[onDebugLog] message: ${data.message}`);
|
|
405
|
+
},
|
|
406
|
+
onSetupDidComplete: () => {
|
|
407
|
+
addLog(`[onSetupDidComplete]`);
|
|
408
|
+
},
|
|
409
|
+
onSetupDidFail: (data: any) => {
|
|
410
|
+
const errorString = JSON.stringify(data);
|
|
411
|
+
setError(errorString);
|
|
412
|
+
addLog(`[onSetupDidFail] error: ${errorString}`);
|
|
413
|
+
},
|
|
414
|
+
onSetupInProgress: (data: any) => {
|
|
415
|
+
addLog(`[onSetupInProgress] progress: ${data.progress}%`);
|
|
416
|
+
},
|
|
417
|
+
onAnalysisResult: (data: any) => {
|
|
418
|
+
setanalysisResult(data);
|
|
419
|
+
setIsAnalyzing(true);
|
|
420
|
+
addLog(`[onAnalysisResult] ${JSON.stringify(data)}`);
|
|
421
|
+
},
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
// register all event listeners
|
|
425
|
+
const subscriptions: (() => void)[] = [];
|
|
426
|
+
|
|
427
|
+
Object.entries(handlers).forEach(([eventType, handler]) => {
|
|
428
|
+
const subscription = emitter.addListener(eventType, handler);
|
|
429
|
+
subscriptions.push(() => subscription.remove());
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
// return cleanup function
|
|
433
|
+
return () => {
|
|
434
|
+
subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
435
|
+
};
|
|
436
|
+
};
|