Skip to content

Commit

Permalink
Update eventEmitter.ts
Browse files Browse the repository at this point in the history
Catch 'unable to auto initialize connection', add optional error callback.
  • Loading branch information
Rammohan Akula authored and hyochan committed Sep 7, 2024
1 parent 0884909 commit d2001a8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/eventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const App = () => {
*/
export const purchaseUpdatedListener = (
listener: (event: Purchase) => void,
errorCallback?: (error: unknown) => void,
) => {
const eventEmitter = new NativeEventEmitter(getNativeModule());
const proxyListener = isIosStorekit2()
Expand All @@ -59,7 +60,13 @@ export const purchaseUpdatedListener = (
);

if (isAndroid) {
getAndroidModule().startListening();
getAndroidModule().startListening().catch((error: unknown) => {
if (errorCallback) {
errorCallback(error);
} else {
throw error;
}
});
}

return emitterSubscription;
Expand Down

0 comments on commit d2001a8

Please sign in to comment.