protected ReactView(IViewModule mainModule) { View = CreateReactViewInstance(Factory); View.Host = this; MainModule = mainModule; // bind main module (this is needed so that the plugins are available right away) View.BindComponent(mainModule); ExtraInitialize(); }
protected ReactView(IViewModule mainModule) { View = CreateReactViewInstance(Factory); SetResourceReference(StyleProperty, typeof(ReactView)); // force styles to be inherited, must be called after view is created otherwise view might be null View.Host = this; MainModule = mainModule; // bind main module (this is needed so that the plugins are available right away) View.BindComponent(mainModule); IsVisibleChanged += OnIsVisibleChanged; Content = View; FocusManager.SetIsFocusScope(this, true); FocusManager.SetFocusedElement(this, View.FocusableElement); }
private static ReactViewRender CreateReactViewInstance(ReactViewFactory factory) { ReactViewRender InnerCreateView() { var view = new ReactViewRender(factory.DefaultStyleSheet, () => factory.InitializePlugins(), factory.EnableViewPreload, factory.EnableDebugMode, factory.DevServerURI); if (factory.ShowDeveloperTools) { view.ShowDeveloperTools(); } return(view); } if (factory.EnableViewPreload) { var factoryType = factory.GetType(); // check if we have a view cached for the current factory if (CachedViews.TryGetValue(factoryType, out var cachedView)) { CachedViews.Remove(factoryType); } // create a new view in the background and put it in the cache Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => { if (!CachedViews.ContainsKey(factoryType) && !Dispatcher.CurrentDispatcher.HasShutdownStarted) { CachedViews.Add(factoryType, InnerCreateView()); } }), DispatcherPriority.Background); if (cachedView != null) { return(cachedView); } } return(InnerCreateView()); }
private static ReactViewRender CreateReactViewInstance(ReactViewFactory factory) { ReactViewRender InnerCreateView() { var view = new ReactViewRender(factory.DefaultStyleSheet, () => factory.InitializePlugins(), factory.EnableViewPreload, factory.MaxNativeMethodsParallelCalls, factory.EnableDebugMode, factory.DevServerURI, factory.RegisterWebJavaScriptObject, factory.UnregisterWebJavaScriptObject, factory.ExecuteWebScriptFunctionWithSerializedParams); if (factory.ShowDeveloperTools) { view.ShowDeveloperTools(); } return(view); } if (factory.EnableViewPreload) { var factoryType = factory.GetType(); // check if we have a view cached for the current factory if (CachedViews.TryGetValue(factoryType, out var cachedView)) { CachedViews.Remove(factoryType); } // create a new view in the background and put it in the cache AsyncExecuteInUI(() => { if (!CachedViews.ContainsKey(factoryType)) { CachedViews.Add(factoryType, InnerCreateView()); } }, lowPriority: true); if (cachedView != null) { return(cachedView); } } return(InnerCreateView()); }
public static void Initialize(ReactViewRender viewRender, Func <string, object, Func <Func <object>, object>, bool, bool> registerWebJavaScriptObject = null, Action <string> unregisterWebJavaScriptObject = null) { new NativeAPI(viewRender, registerWebJavaScriptObject); }
private NativeAPI(ReactViewRender viewRender, Func <string, object, Func <Func <object>, object>, bool, bool> registerWebJavaScriptObject = null) { ViewRender = viewRender; ViewRender.WebView.RegisterJavascriptObject(NativeObjectName, this); registerWebJavaScriptObject(NativeObjectName, this, null, false); }
public LoaderModule(ReactViewRender viewRender) { ViewRender = viewRender; }
public static void Initialize(ReactViewRender viewRender) { new NativeAPI(viewRender); }
private NativeAPI(ReactViewRender viewRender) { ViewRender = viewRender; ViewRender.WebView.RegisterJavascriptObject(NativeObjectName, this); }