Procházet zdrojové kódy

Fix concurrent modification exception

Guy Carmeli před 8 roky
rodič
revize
d72845a4fe

+ 3
- 1
android/app/src/main/java/com/reactnativenavigation/events/EventBus.java Zobrazit soubor

@@ -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);