Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #119 - Cleans up ReactInstanceManager and ReactRootView #120

Merged
merged 1 commit into from
Jan 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions ReactWindows/Playground/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using ReactNative;
using ReactNative.Shell;
using System;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace Playground
Expand All @@ -22,6 +15,8 @@ namespace Playground
/// </summary>
sealed partial class App : Application
{
private readonly ReactPage _reactPage;

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
Expand All @@ -33,6 +28,13 @@ public App()
Microsoft.ApplicationInsights.WindowsCollectors.Session);
this.InitializeComponent();
this.Suspending += OnSuspending;
this.Resuming += OnResuming;

_reactPage = new ReactPage(
"ms-appx:///Resources/main.dev.jsbundle",
"ReactRoot",
new[] { new MainReactPackage() }.ToList(),
() => { /* TODO: back button handling */ });
}

/// <summary>
Expand All @@ -42,6 +44,8 @@ public App()
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
_reactPage.OnCreate();
_reactPage.OnResume();

#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
Expand Down Expand Up @@ -75,8 +79,9 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
rootFrame.Content = _reactPage;
}

// Ensure the current window is active
Window.Current.Activate();
}
Expand All @@ -101,8 +106,21 @@ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();

//TODO: Save application state and stop any background activity
_reactPage.OnSuspend();

deferral.Complete();
}

/// <summary>
/// Invoked when application execution is being resumed.
/// </summary>
/// <param name="sender">The source of the resume request.</param>
/// <param name="e">Details about the resume request.</param>
private void OnResuming(object sender, object e)
{
_reactPage.OnResume();
}
}
}
14 changes: 0 additions & 14 deletions ReactWindows/Playground/MainPage.xaml

This file was deleted.

46 changes: 0 additions & 46 deletions ReactWindows/Playground/MainPage.xaml.cs

This file was deleted.

7 changes: 0 additions & 7 deletions ReactWindows/Playground/Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand All @@ -130,10 +127,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ReactNative\ReactNative.csproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task CatalystInstance_GetModules()
QueueConfigurationSpec = CatalystQueueConfigurationSpec.Default,
Registry = registry,
JavaScriptModulesConfig = jsConfig,
JavaScriptExecutor = executor,
JavaScriptExecutorFactory = () => executor,
BundleLoader = JavaScriptBundleLoader.CreateFileLoader("ms-appx:///Resources/test.js"),
NativeModuleCallExceptionHandler = _ => { }
};
Expand Down Expand Up @@ -63,7 +63,7 @@ public async Task CatalystInstance_Initialize_Dispose()
QueueConfigurationSpec = CatalystQueueConfigurationSpec.Default,
Registry = registry,
JavaScriptModulesConfig = jsConfig,
JavaScriptExecutor = executor,
JavaScriptExecutorFactory = () => executor,
BundleLoader = JavaScriptBundleLoader.CreateFileLoader("ms-appx:///Resources/test.js"),
NativeModuleCallExceptionHandler = _ => { },
};
Expand Down Expand Up @@ -109,7 +109,7 @@ public async Task CatalystInstance_ExceptionHandled_Disposes()
QueueConfigurationSpec = CatalystQueueConfigurationSpec.Default,
Registry = registry,
JavaScriptModulesConfig = jsConfig,
JavaScriptExecutor = executor,
JavaScriptExecutorFactory = () => executor,
BundleLoader = JavaScriptBundleLoader.CreateFileLoader("ms-appx:///Resources/test.js"),
NativeModuleCallExceptionHandler = handler,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public void ReactContextNativeModuleBase_ArgumentChecks()
() => new TestModule(null),
ex => Assert.AreEqual("reactContext", ex.ParamName));

var context = new ReactApplicationContext();
var context = new ReactContext();
var module = new TestModule(context);
Assert.AreSame(context, module.Context);
}

class TestModule : ReactContextNativeModuleBase
{
public TestModule(ReactApplicationContext reactContext)
public TestModule(ReactContext reactContext)
: base(reactContext)
{
}
Expand Down
2 changes: 0 additions & 2 deletions ReactWindows/ReactNative.Tests/Internal/JavaScriptHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public static async Task Initialize(ChakraJavaScriptExecutor executor, IMessageQ

await jsQueueThread.CallOnQueue(() =>
{
executor.Initialize();

foreach (var script in scripts)
{
executor.RunScript(script);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void ToastModule_Null_ArgumentsTest()
ex => Assert.AreEqual("reactContext", ex.ParamName));


var context = new ReactApplicationContext();
var context = new ReactContext();
var module = new ToastModule(context);
Assert.AreSame(context, module.Context);

Expand All @@ -29,7 +29,7 @@ public void ToastModule_Null_ArgumentsTest()
[TestCategory(TEST_CATEGORY)]
public void Send_Toast_Invalid_Duration()
{
var context = new ReactApplicationContext();
var context = new ReactContext();
var module = new ToastModule(context);

AssertEx.Throws<ArgumentException>(
Expand All @@ -41,7 +41,7 @@ public void Send_Toast_Invalid_Duration()
[TestCategory(TEST_CATEGORY)]
public void Send_Basic_Toast()
{
var context = new ReactApplicationContext();
var context = new ReactContext();
var module = new ToastModule(context);

module.show("SHORT TOAST", 0);
Expand All @@ -51,7 +51,7 @@ public void Send_Basic_Toast()
[TestCategory(TEST_CATEGORY)]
public void Send_Long_Toast()
{
var context = new ReactApplicationContext();
var context = new ReactContext();
var module = new ToastModule(context);

module.show("LONG TOAST container", 1);
Expand Down
Loading