Synchronously fail when calling JS too early

Differential Revision: D3453476

fbshipit-source-id: 3fbfda46b4cb7d31f554df6760c5146c412ff468
This commit is contained in:
Chris Hopman 2016-06-20 12:43:41 -07:00 committed by Facebook Github Bot 3
parent cc8cf8f0f2
commit 6128b7236f
2 changed files with 9 additions and 1 deletions

View File

@ -137,7 +137,12 @@ public class ReactTestHelper {
return null;
}
}).get();
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
instance.initialize();
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -191,6 +191,9 @@ public class CatalystInstanceImpl implements CatalystInstance {
FLog.w(ReactConstants.TAG, "Calling JS function after bridge has been destroyed.");
return;
}
if (!mInitialized) {
throw new RuntimeException("Attempt to call JS function before instance initialization.");
}
callJSFunction(executorToken, module, method, arguments, tracingName);
}