/** * Set and initialize CatalystInstance for this Context. This should be called exactly once. */ public void initializeWithInstance(CatalystInstance catalystInstance) { if (catalystInstance == null) { throw new IllegalArgumentException("CatalystInstance cannot be null."); } if (mCatalystInstance != null) { throw new IllegalStateException("ReactContext has been already initialized"); } mCatalystInstance = catalystInstance; ReactQueueConfiguration queueConfig = catalystInstance.getReactQueueConfiguration(); mUiMessageQueueThread = queueConfig.getUIQueueThread(); mNativeModulesMessageQueueThread = queueConfig.getNativeModulesQueueThread(); mJSMessageQueueThread = queueConfig.getJSQueueThread(); }
/** * @return a CatalystInstance mock that has a default working ReactQueueConfiguration. */ public static CatalystInstance createMockCatalystInstance() { ReactQueueConfigurationSpec spec = ReactQueueConfigurationSpec.builder() .setJSQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec()) .setNativeModulesQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec()) .build(); ReactQueueConfiguration ReactQueueConfiguration = ReactQueueConfigurationImpl.create( spec, new QueueThreadExceptionHandler() { @Override public void handleException(Exception e) { throw new RuntimeException(e); } }); CatalystInstance reactInstance = mock(CatalystInstance.class); when(reactInstance.getReactQueueConfiguration()).thenReturn(ReactQueueConfiguration); when(reactInstance.getNativeModule(UIManagerModule.class)) .thenReturn(mock(UIManagerModule.class)); return reactInstance; }
@Override public ReactQueueConfiguration getReactQueueConfiguration() { return mReactQueueConfiguration; }
ReactQueueConfiguration getReactQueueConfiguration();