コード例 #1
0
        public string GetJavaScriptBundleFile(string assetsBundleFileName)
        {
            if (CurrentInstance == null)
            {
                throw new InvalidOperationException("A GreatPush instance has not been created yet. Have you added it to your app's list of ReactPackages?");
            }

            return(CurrentInstance.GetJavaScriptBundleFileAsync(assetsBundleFileName).Result);
        }
コード例 #2
0
        internal async Task LoadBundleAsync()
        {
            // #1) Get the private ReactInstanceManager, which is what includes
            //     the logic to reload the current React context.
            var reactInstanceManager = _greatPush.ReactInstanceManager;

            // #2) Update the locally stored JS bundle file path
            Type   reactInstanceManagerType = typeof(ReactInstanceManager);
            string latestJSBundleFile       = await _greatPush.GetJavaScriptBundleFileAsync(_greatPush.AssetsBundleFileName).ConfigureAwait(false);

            reactInstanceManagerType
            .GetField("_jsBundleFile", BindingFlags.NonPublic | BindingFlags.Instance)
            .SetValue(reactInstanceManager, latestJSBundleFile);

            // #3) Get the context creation method and fire it on the UI thread (which RN enforces)
            Context.RunOnDispatcherQueueThread(() => reactInstanceManager.RecreateReactContextAsync(CancellationToken.None));
        }