Skip to content

Commit

Permalink
Resolved listener issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AJAYJ-09 committed Jun 12, 2024
1 parent e17ad2d commit 514b8d1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions android/src/main/java/sqip/react/SquareInAppPaymentsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,24 @@ public void run() {
}
});
}

@ReactMethod
public void addListener(String eventName) {
if (!listeners.containsKey(eventName)) {
listeners.put(eventName, 1);
} else {
listeners.put(eventName, listeners.get(eventName) + 1);
} }

@ReactMethod
public void removeListeners(Integer count) {
for (Map.Entry<String, Integer> entry : listeners.entrySet()) {
int currentCount = entry.getValue();
if (currentCount <= count) {
listeners.remove(entry.getKey());
} else {
listeners.put(entry.getKey(), currentCount - count);
}
} }
}

0 comments on commit 514b8d1

Please sign in to comment.