mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 22:41:18 +08:00
Implement onViewAppear by creating a new EventListener on ReactRootView listening for when it's attached to a RN Instance
Reviewed By: AaaChiuuu Differential Revision: D4269272 fbshipit-source-id: 6dd54f8ab7befebd54e82ef355119ba302b9bfe5
This commit is contained in:
committed by
Facebook Github Bot
parent
7f8c2985a8
commit
bfe551d2d1
@@ -56,10 +56,21 @@ import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
*/
|
||||
public class ReactRootView extends SizeMonitoringFrameLayout implements RootView {
|
||||
|
||||
/**
|
||||
* Listener interface for react root view events
|
||||
*/
|
||||
public interface ReactRootViewEventListener {
|
||||
/**
|
||||
* Called when the react context is attached to a ReactRootView.
|
||||
*/
|
||||
void onAttachedToReactInstance(ReactRootView rootView);
|
||||
}
|
||||
|
||||
private @Nullable ReactInstanceManager mReactInstanceManager;
|
||||
private @Nullable String mJSModuleName;
|
||||
private @Nullable Bundle mLaunchOptions;
|
||||
private @Nullable CustomGlobalLayoutListener mCustomGlobalLayoutListener;
|
||||
private @Nullable ReactRootViewEventListener mRootViewEventListener;
|
||||
private int mRootViewTag;
|
||||
private boolean mWasMeasured = false;
|
||||
private boolean mIsAttachedToInstance = false;
|
||||
@@ -224,6 +235,16 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
|
||||
}
|
||||
}
|
||||
|
||||
public void onAttachedToReactInstance() {
|
||||
if (mRootViewEventListener != null) {
|
||||
mRootViewEventListener.onAttachedToReactInstance(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEventListener(ReactRootViewEventListener eventListener) {
|
||||
mRootViewEventListener = eventListener;
|
||||
}
|
||||
|
||||
/* package */ String getJSModuleName() {
|
||||
return Assertions.assertNotNull(mJSModuleName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user