Prepares CatalystInstance for implementation of ReactContext.

This commit is contained in:
Eric Rozell 2015-12-22 15:32:54 -05:00
Родитель d2c7149383
Коммит 2a462214fb
2 изменённых файлов: 28 добавлений и 5 удалений

Просмотреть файл

@ -14,10 +14,12 @@ namespace ReactNative.Bridge
class CatalystInstance : ICatalystInstance, IDisposable
{
private readonly NativeModuleRegistry _registry;
private readonly CatalystQueueConfiguration _catalystQueueConfiguration;
private readonly ICatalystQueueConfiguration _catalystQueueConfiguration;
private readonly IJavaScriptExecutor _jsExecutor;
private readonly JavaScriptModulesConfig _jsModulesConfig;
private readonly Action<Exception> _nativeModuleCallsExceptionHandler;
private readonly JavaScriptModuleRegistry _jsRegistry;
private IReactBridge _bridge;
private bool _initialized;
@ -27,13 +29,16 @@ namespace ReactNative.Bridge
CatalystQueueConfigurationSpec catalystQueueConfigurationSpec,
IJavaScriptExecutor jsExecutor,
NativeModuleRegistry registry,
JavaScriptModulesConfig jsModulesConfig)
JavaScriptModulesConfig jsModulesConfig,
Action<Exception> nativeModuleCallsExceptionHandler)
{
_registry = registry;
_jsExecutor = jsExecutor;
_jsModulesConfig = jsModulesConfig;
_nativeModuleCallsExceptionHandler = nativeModuleCallsExceptionHandler;
_jsRegistry = new JavaScriptModuleRegistry(this, _jsModulesConfig);
_catalystQueueConfiguration = CatalystQueueConfiguration.Create(
QueueConfiguration = CatalystQueueConfiguration.Create(
catalystQueueConfigurationSpec,
HandleException);
}
@ -46,6 +51,16 @@ namespace ReactNative.Bridge
}
}
public ICatalystQueueConfiguration QueueConfiguration
{
get;
}
public T GetJavaScriptModule<T>() where T : IJavaScriptModule
{
return _jsRegistry.GetJavaScriptModule<T>();
}
public T GetNativeModule<T>() where T : INativeModule
{
return _registry.GetModule<T>();
@ -169,7 +184,8 @@ namespace ReactNative.Bridge
private void HandleException(Exception ex)
{
// TODO
_nativeModuleCallsExceptionHandler(ex);
QueueConfiguration.DispatcherQueueThread.RunOnQueue(Dispose);
}
class NativeModulesReactCallback : IReactCallback

Просмотреть файл

@ -39,6 +39,13 @@ namespace ReactNative.Bridge
/// <param name="arguments">The arguments.</param>
void InvokeCallback(int callbackId, JArray arguments);
/// <summary>
/// Gets a JavaScript module instance.
/// </summary>
/// <typeparam name="T">Type of JavaScript module.</typeparam>
/// <returns>The JavaScript module instance.</returns>
T GetJavaScriptModule<T>() where T : IJavaScriptModule;
/// <summary>
/// Gets a native module instance.
/// </summary>