add removeReactInstanceEventListener and call it from onDestroy
Reviewed By: zahanm Differential Revision: D2937547 fb-gh-sync-id: 95461fdada8ac86d2c4174dae7023c97a3101e2e shipit-source-id: 95461fdada8ac86d2c4174dae7023c97a3101e2e
This commit is contained in:
parent
f74981ac32
commit
07a5f4407f
|
@ -136,6 +136,11 @@ public abstract class ReactInstanceManager {
|
|||
*/
|
||||
public abstract void addReactInstanceEventListener(ReactInstanceEventListener listener);
|
||||
|
||||
/**
|
||||
* Remove a listener previously added with {@link #addReactInstanceEventListener}.
|
||||
*/
|
||||
public abstract void removeReactInstanceEventListener(ReactInstanceEventListener listener);
|
||||
|
||||
@VisibleForTesting
|
||||
public abstract @Nullable ReactContext getCurrentReactContext();
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -110,7 +113,7 @@ import static com.facebook.react.bridge.ReactMarkerConstants.*;
|
|||
private String mSourceUrl;
|
||||
private @Nullable Activity mCurrentActivity;
|
||||
private final Collection<ReactInstanceEventListener> mReactInstanceEventListeners =
|
||||
new ConcurrentLinkedQueue<>();
|
||||
Collections.synchronizedSet(new HashSet<ReactInstanceEventListener>());
|
||||
private volatile boolean mHasStartedCreatingInitialContext = false;
|
||||
private final UIImplementationProvider mUIImplementationProvider;
|
||||
private final MemoryPressureRouter mMemoryPressureRouter;
|
||||
|
@ -599,6 +602,11 @@ import static com.facebook.react.bridge.ReactMarkerConstants.*;
|
|||
mReactInstanceEventListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeReactInstanceEventListener(ReactInstanceEventListener listener) {
|
||||
mReactInstanceEventListeners.remove(listener);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@Override
|
||||
public @Nullable ReactContext getCurrentReactContext() {
|
||||
|
|
Loading…
Reference in New Issue