Commit e06b8db 1 parent 5144bf0 commit e06b8db Copy full SHA for e06b8db
File tree 2 files changed +22
-0
lines changed
ReactAndroid/src/main/java/com/facebook/react
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 56
56
*/
57
57
public class ReactRootView extends SizeMonitoringFrameLayout implements RootView {
58
58
59
+ /**
60
+ * Listener interface for react root view events
61
+ */
62
+ public interface ReactRootViewEventListener {
63
+ /**
64
+ * Called when the react context is attached to a ReactRootView.
65
+ */
66
+ void onAttachedToReactInstance (ReactRootView rootView );
67
+ }
68
+
59
69
private @ Nullable ReactInstanceManager mReactInstanceManager ;
60
70
private @ Nullable String mJSModuleName ;
61
71
private @ Nullable Bundle mLaunchOptions ;
62
72
private @ Nullable CustomGlobalLayoutListener mCustomGlobalLayoutListener ;
73
+ private @ Nullable ReactRootViewEventListener mRootViewEventListener ;
63
74
private int mRootViewTag ;
64
75
private boolean mWasMeasured = false ;
65
76
private boolean mIsAttachedToInstance = false ;
@@ -224,6 +235,16 @@ public void unmountReactApplication() {
224
235
}
225
236
}
226
237
238
+ public void onAttachedToReactInstance () {
239
+ if (mRootViewEventListener != null ) {
240
+ mRootViewEventListener .onAttachedToReactInstance (this );
241
+ }
242
+ }
243
+
244
+ public void setEventListener (ReactRootViewEventListener eventListener ) {
245
+ mRootViewEventListener = eventListener ;
246
+ }
247
+
227
248
/* package */ String getJSModuleName () {
228
249
return Assertions .assertNotNull (mJSModuleName );
229
250
}
Original file line number Diff line number Diff line change @@ -810,6 +810,7 @@ private void attachMeasuredRootViewToInstance(
810
810
appParams .putDouble ("rootTag" , rootTag );
811
811
appParams .putMap ("initialProps" , initialProps );
812
812
catalystInstance .getJSModule (AppRegistry .class ).runApplication (jsAppModuleName , appParams );
813
+ rootView .onAttachedToReactInstance ();
813
814
Systrace .endSection (TRACE_TAG_REACT_JAVA_BRIDGE );
814
815
}
815
816
You can’t perform that action at this time.
0 commit comments