浏览代码

Fix concurrent modification exception

Guy Carmeli 8 年前
父节点
当前提交
d72845a4fe
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3
    1
      android/app/src/main/java/com/reactnativenavigation/events/EventBus.java

+ 3
- 1
android/app/src/main/java/com/reactnativenavigation/events/EventBus.java 查看文件

@@ -27,7 +27,9 @@ public enum EventBus {
27 27
     }
28 28
 
29 29
     public void post(Event event) {
30
-        for (WeakReference<Subscriber> ref : subscribers) {
30
+        ListIterator<WeakReference<Subscriber>> iterator = subscribers.listIterator();
31
+        while (iterator.hasNext()) {
32
+            WeakReference<Subscriber> ref = iterator.next();
31 33
             Subscriber registered = ref.get();
32 34
             if (registered != null) {
33 35
                 registered.onEvent(event);